using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators;namespace WealthLab.Strategies { public class TASC201608 : WealthScript { private StrategyParameter slider1; private StrategyParameter slider2; private StrategyParameter slider3; public TASC201608() { slider1 = CreateParameter("MHL Period",3,2,300,20); slider2 = CreateParameter("MA Period",10,2,300,20); slider3 = CreateParameter("SMA(0) or EMA (1)",0,0,1,1); } protected override void Execute() { int movAvgPeriod = slider2.ValueInt; bool isEMA = slider3.ValueInt == 0 ? false : true; var mhl = MHLMA.Series(Bars,slider1.ValueInt,slider2.ValueInt, isEMA ? WhichMA.EMA : WhichMA.SMA); DataSeries ema = EMA.Series(Close,movAvgPeriod,EMACalculation.Modern); DataSeries sma = SMA.Series(Close,movAvgPeriod); PlotSeries(PricePane,mhl,Color.Red,LineStyle.Solid,1); PlotSeries(PricePane,isEMA ? ema : sma,Color.DarkGreen,LineStyle.Solid,1); for(int bar = GetTradingLoopStartBar(1); bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( CrossUnder(bar,isEMA?ema:sma,mhl) ) SellAtMarket(bar+1, LastPosition); } else { if( CrossOver(bar,isEMA?ema:sma,mhl) ) BuyAtMarket(bar+1, isEMA.ToString()); } } } } }