using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators;namespace WealthLab.Strategies { public class PendergastStrategy : WealthScript { protected override void Execute() { double tick = Bars.SymbolInfo.Tick; DataSeries ema50 = EMAModern.Series(Close, 50); SMA maH = SMA.Series(High, 5); SMA maL = SMA.Series(Low, 5); HighestBar h = HighestBar.Series( High, 50 ); LowestBar l = LowestBar.Series( Low, 50 ); SeriesIsAbove risingLows = SeriesIsAbove.Series( Low, maL, 1); SeriesIsBelow decliningHighs = SeriesIsBelow.Series( High, maH, 1); HideVolume(); PlotSeries(PricePane,maH,Color.Gold,LineStyle.Solid,2); PlotSeries(PricePane,maL,Color.Red,LineStyle.Solid,2); PlotSeries(PricePane,ema50,Color.Blue,LineStyle.Solid,2); for(int bar = GetTradingLoopStartBar(51); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (p.PositionType == PositionType.Short) CoverAtStop( bar + 1, p, maH[bar] ); else SellAtStop( bar + 1, p, maL[bar] ); } else { if( decliningHighs[bar] >= 2 ) if( h[bar] > l[bar] ) if (Close[bar] > ema50[bar]) BuyAtStop(bar + 1, maH[bar] + 5 * tick); if( risingLows[bar] >= 2 ) if( l[bar] > h[bar] ) if (Close[bar] < ema50[bar]) ShortAtStop(bar + 1, maL[bar] - 5 * tick ); } } } } }