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() { for(int bar = GetTradingLoopStartBar(2); bar < Bars.Count; bar++) { bool PivotLow = (Low[bar-1] < Low[bar-2]) && (Low[bar-1] < Low[bar]); bool PivotHigh = (High[bar-1] > High[bar-2]) && (High[bar-1] > High[bar]); if (IsLastPositionActive) { Position p = LastPosition; if (bar+1 - p.EntryBar >= 20) ExitAtMarket( bar+1, p, "After 4 weeks" ); } else { if (PivotLow) BuyAtMarket(bar+1); else if (PivotHigh) ShortAtMarket(bar+1); } } } } }