Total number of bars in the simulation, determined from Lookback, StartDate and EndDate and from the available data in the price history files. Is 0 in the initial run before the first asset call.
Current bar number including the lookback period and preceding history, usually from 0 to NumBars-1. The number is not always counted up straight since bars can be skipped (see remarks).
Number of the first bar after the lookback period. (Bar-StartBar) is the current length of the test period in bars. (StartBar-LookBack) is the number of the first bar after the INITRUN.
Current trading day number of the simulation, starting with the end of the lookback period. Periods with no bars, such as weekends and holidays, are skipped.
int, normally read/only
- NumBars and StartBar are only valid after the asset was loaded.
- The Bar number is increased on every run, but not always by 1. Bars are skipped when they are not used in the simulation, f.i. when the simulation starts at a certain StartDate, or when WFO cycles are trained. Bars from the price history preceding the LookBack period are then skipped, causing Bar to start with a high number after the initial run.
- For running a simulation in greater steps as a bar period for special purposes (f.i. for generating histograms), bars can be skipped by adding a number to Bar at the end of the run function. F.i. Bar += 9; will call the run function only every 10th bar. Setting Bar = NumBars aborts the simulation. Use this hack at own risk since TimeFrame and series do not consider bars that are skipped this way.
- The number of bars spent in drawdown, and other bar statistics at the end of the simulation can be found under Strategy statistics.
printf("\nBar %i of %i",Bar,NumBars);
Bars, BarPeriod, BarOffset, LookBack, StartDate, run
► latest version online