DataSeries NegativeCloses( DataSeries ds, int Lookback )
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 ClosesStrategy : WealthScript { protected override void Execute() { DataSeries pc = PositiveCloses.Series( Close, 3 ); DataSeries nc = NegativeCloses.Series( Low, 5 ); ChartPane closesPane = CreatePane( 25, true, true ); PlotSeries( closesPane, pc, Color.Blue, LineStyle.Solid, 2 ); PlotSeries( closesPane, nc, Color.Red, LineStyle.Solid, 2 ); for(int bar = 5; bar < Bars.Count; bar++) { if (IsLastPositionActive) { // Sell when the last 2 of 3 closes are higher if (pcbar >= 2) ExitAtMarket(bar + 1, LastPosition); } else { // Buy when the last 4 of 5 lows are lower if (ncbar >= 4) BuyAtMarket(bar + 1); } } } } }