using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators;namespace WealthLab.Strategies { public class TASCJuly2019 : WealthScript { private StrategyParameter paramPeriod; private StrategyParameter paramDev; private StrategyParameter paramExit; public TASCJuly2019() { paramPeriod = CreateParameter("Period",20,10,100,10); paramDev = CreateParameter("Deviations",2,0.5,4,0.5); paramExit = CreateParameter("Exit after",10,2,40,2); } protected override void Execute() { var period = paramPeriod.ValueInt; var dev = paramDev.Value; int exitAfter = paramExit.ValueInt; var adx = ADX.Series( Bars, period); var ma = SMA.Series( Close, period); var ebu = ExpDevBandUpper.Series( Close, period,dev,false); var ebl = ExpDevBandLower.Series( Close, period,dev,false); ChartPane adxPane = CreatePane( 20, false, true); PlotSeries( adxPane, adx, Color.Black, LineStyle.Solid, 1); PlotSeriesFillBand( PricePane, ebl,ebu,Color.Red,Color.Transparent,LineStyle.Solid,1); PlotSeries( PricePane, ma, Color.Red, LineStyle.Solid, 1 ); HideVolume(); for(int bar = GetTradingLoopStartBar(1); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (bar+1 - p.EntryBar >= exitAfter) SellAtMarket( bar+1, p, "Timed exit"); else if(adxbar > adxbar - 10 ) ExitAtMarket( bar+1, p, "Trend alert"); } else { if(adxbar < adxbar - period) BuyAtLimit( bar+1, eblbar); } } } } }