using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { var adx = ADX.Series(Bars,10); var macd = MACD.Series(Close); var cci = CCI.Series(Bars,14); var ema = EMAModern.Series(Close,13); var days = 10; SetBarColors( Color.Silver,Color.Silver); var ls = LineStyle.Solid; var cp = CreatePane( 30,true,true); var mp = CreatePane( 30,true,true); var ap = CreatePane( 30,true,true); PlotSeries( mp, macd, Color.DarkGreen, ls, 2 ); PlotSeries( ap, adx, Color.Red, ls, 2 ); PlotSeries( cp, cci, Color.Black, LineStyle.Histogram, 2 ); PlotSeries( PricePane, ema, Color.Gray, ls, 2 ); for(int bar = GetTradingLoopStartBar( 14 * 3); bar < Bars.Count; bar++) { bool CAM_UP = (adx[bar] >= adx[bar-1]) & (macd[bar] > macd[bar-1]); bool CAM_PB = (adx[bar] <= adx[bar-1]) & (macd[bar] < macd[bar-1]); bool CAM_DN = (adx[bar] >= adx[bar-1]) & (macd[bar] < macd[bar-1]); bool CAM_CT = (adx[bar] <= adx[bar-1]) & (macd[bar] > macd[bar-1]); bool buyPullback = (CAM_PB && (cci[bar] > 0)) || (CAM_CT && CrossOver( bar,Close,ema)); SetBarColor( bar, CAM_UP ? Color.Green : CAM_PB ? Color.Gold: CAM_DN ? Color.Red : CAM_CT ? Color.DarkBlue : Color.Black ); SetSeriesBarColor( bar, cci, cci[bar] < 0 ? Color.Red : Color.Green ); if (IsLastPositionActive) { Position p = LastPosition; if( CAM_DN && (Close[bar] < ema[bar]) ) SellAtMarket( bar+1, p, "CAM-DN" ); } else { if(buyPullback) { AnnotateBar("v",bar,false,Color.Black); BuyAtMarket( bar+1); } } } } } }