public static int BarsSince(this int bar, bool condition )public int BarsSince(int bar, bool condition )
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class BarsSinceDemo : WealthScript { protected override void Execute() { DataSeries barsSince = new DataSeries(Bars,"Bars Since Breakout(40)"); int b1 = 0; int markbar = 0; // Building BarsSinceBreakout series for(int bar = 41; bar < Bars.Count; bar++) { if( bar.BarsSince( ( High[bar] > Highest.Series(High,40)[bar-1] ) ) == 0 ) markbar = bar; barsSince[bar] = bar - markbar; } PlotSeries( PricePane, Highest.Series(High,40), Color.Blue, LineStyle.Dashed, 2 ); SetBarColors( Color.Silver,Color.Silver ); ChartPane bscPane = CreatePane(30,true,true); PlotSeries(bscPane, barsSince, Color.Blue, LineStyle.Histogram, 3 ); } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; // BarsSince here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class BarsSinceDemo : WealthScript { protected override void Execute() { Calculate c = new Calculate(this); // pass an instance of the WealthScript object DataSeries barsSince = new DataSeries(Bars,"Bars Since Breakout(40)"); int b1 = 0; int markbar = 0; // Building BarsSinceBreakout series for(int bar = 41; bar < Bars.Count; bar++) { if( c.BarsSince( bar, ( High[bar] > Highest.Series(High,40)[bar-1] ) ) == 0 ) markbar = bar; barsSince[bar] = bar - markbar; } PlotSeries( PricePane, Highest.Series(High,40), Color.Blue, LineStyle.Dashed, 2 ); SetBarColors( Color.Silver,Color.Silver ); ChartPane bscPane = CreatePane(30,true,true); PlotSeries(bscPane, barsSince, Color.Blue, LineStyle.Histogram, 3 ); } } }
The BarsSinceBreakout series created