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, maHbar ); else SellAtStop( bar + 1, p, maLbar ); } else { if( decliningHighsbar >= 2 ) if( hbar > lbar ) if (Closebar > ema50bar) BuyAtStop(bar + 1, maHbar + 5 * tick); if( risingLowsbar >= 2 ) if( lbar > hbar ) if (Closebar < ema50bar) ShortAtStop(bar + 1, maLbar - 5 * tick ); } } } } }