Log in to see Cloud of Tags

Wealth-Lab Wiki

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

RSS

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( tpEmabar < haEmabar ) ... if( CrossOver( bar, tpEma, haEma ) ) //if( tpEmabar > haEmabar )

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 = HObar-1; double c1 = HCbar-1; HObar = ( o1 + c1 ) / 2; HHbar = Math.Max( HObar, Highbar ); HLbar = Math.Min( HObar, Lowbar ); bars.Add( Bars.Datebar, HObar, HHbar, HLbar, HCbar, Bars.Volumebar); } 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, (svebar > 0) ? Color.LightGreen : Color.Black ); if (IsLastPositionActive) { Position p = LastPosition; if( Closebar < Openbar ) { double stopLoss = (1.0 - paramSL.Value / 100d); double stop = p.EntryPrice * stopLoss; double brkEven = p.EntryPrice * 1.01;

if( CrossUnder( bar, tpEma, haEma ) ) //if( tpEmabar < haEmabar ) 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( Closebar > Openbar ) { if( CrossOver( bar, tpEma, haEma ) ) //if( tpEmabar > haEmabar ) BuyAtMarket( bar+1 ); } } } } } }


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

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.