TASC 2013-10 | An Expert Of A System (Vervoort)

Modified on 2016/01/10 20:31 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

This month's "An Expert of a System" is the sixth part of Sylvain Vervoort's series of articles. The featured SVEHaTypCross indicator is rather simple in its construction and application, double smoothing the source series by applying an EMA on the typical price and the Heikin-Ashi series.

As an illustration, we provide both the SVEHaTypCross indicator (that can be applied to any chart via drag & drop and utilized in rule- and code-based strategies) and a strategy based on the trading rules from this month's article.

While author's approach in the article code only checks if the Typical average is above (or below) the Heikin-Ashi average, using a true crossover/crossunder may be beneficial as it triggers less signals. A true crossover happens when the 1st average is above the 2nd one and the previous value was less than or equal to the target value at the previous bar. Motivated traders can compare approaches by commenting and uncommenting these lines:


	if( CrossUnder( bar, tpEma, haEma ) )
	//if( tpEma[bar] < haEma[bar] )
		...
	if( CrossOver( bar, tpEma, haEma ) )
	//if( tpEma[bar] > haEma[bar] )

To run the sample Strategy in Wealth-Lab, you'll need the TASCIndicators library version 2013.09 or higher. Please install (or update) the library from our wealth-lab.com website to its latest version.

Image

Figure 1. A Wealth-Lab 6 chart illustrating the application of the SVEHATypCross strategy and the SVEHATypCross indicator. Up bars highlighted in green, down bars – in black.


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;

namespace WealthLab.Strategies { public class SVEHATypCrossStrategy : WealthScript { private StrategyParameter paramHAPer; private StrategyParameter paramTypPer; private StrategyParameter paramBrkEven; private StrategyParameter paramSL; public SVEHATypCrossStrategy() { paramHAPer = CreateParameter("H-A Period", 8, 6, 9, 1); paramTypPer = CreateParameter("Typical period", 5, 4, 6, 1); paramBrkEven = CreateParameter("Breakeven stop %", 10, 2, 10, 2); paramSL = CreateParameter("Stop Loss %", 9, 2, 10, 1); } protected override void Execute() { // Parameters int perHA = paramHAPer.ValueInt, perTyp = paramTypPer.ValueInt; EMACalculation m = EMACalculation.Modern; // Create a Heikin-Ashi chart SVEHaTypCross sve = SVEHaTypCross.Series( Bars, perHA, perTyp ); Bars bars = new Bars( Bars.Symbol.ToString() + " (Heikin-Ashi)", Bars.Scale, Bars.BarInterval ); // Heikin-Ashi series DataSeries HO = Open + 0, HH = High + 0, HL = Low + 0; DataSeries HC = (Open + High + Low + Close) / 4; // Build the Bars object for (int bar = 1; bar < Bars.Count; bar++) { double o1 = HO[bar-1]; double c1 = HC[bar-1]; HO[bar] = ( o1 + c1 ) / 2; HH[bar] = Math.Max( HO[bar], High[bar] ); HL[bar] = Math.Min( HO[bar], Low[bar] ); bars.Add( Bars.Date[bar], HO[bar], HH[bar], HL[bar], HC[bar], Bars.Volume[bar]); } bars = Synchronize( bars ); // Build EMA of Heikin-Ashi close and EMA of Typical price EMA haEma = EMA.Series(bars.Close, perHA, m); EMA tpEma = EMA.Series(AveragePriceC.Series( Bars ), perTyp, m); // Plot the series ChartPane haPane = CreatePane(75, false, true); ChartPane svePane = CreatePane(10, false, true); PlotSymbol(haPane, bars, Color.DodgerBlue, Color.Red); PlotSeries(haPane, haEma, Color.Red, LineStyle.Solid, 1); PlotSeries(haPane, tpEma, Color.Green, LineStyle.Solid, 1); PlotSeries(svePane, sve, Color.Blue, LineStyle.Solid, 1); SetBarColors(Color.Silver, Color.Silver); HideVolume(); for(int bar = 1; bar < Bars.Count; bar++) { SetBarColor(bar, (sve[bar] > 0) ? Color.LightGreen : Color.Black ); if (IsLastPositionActive) { Position p = LastPosition; if( Close[bar] < Open[bar] ) { double stopLoss = (1.0 - paramSL.Value / 100d); double stop = p.EntryPrice * stopLoss; double brkEven = p.EntryPrice * 1.01;

if( CrossUnder( bar, tpEma, haEma ) ) //if( tpEma[bar] < haEma[bar] ) SellAtMarket( bar+1, p, "Regular" ); else if( !SellAtStop(bar + 1, p, stop, "SL")) if (p.MFEAsOfBarPercent(bar) > paramBrkEven.Value) SellAtStop(bar + 1, p, brkEven, "Breakeven"); } } else { if( Close[bar] > Open[bar] ) { if( CrossOver( bar, tpEma, haEma ) ) //if( tpEma[bar] > haEma[bar] ) BuyAtMarket( bar+1 ); } } } } } }

Eugene
Wealth-Lab team
www.wealth-lab.com