ProcessingBarSeriesIndex

Description

Within a multi bars script, multiple bars objects are available. The OnCalculate() method will therefore also be called up for every bar within your script. In order to include/exclude events of specific data series, you can use the ProcessingBarSeriesIndex property.
ProcessingBarSeriesIndex is only of value for indicators or strategies that use data from multiple timeframes. With [TimeFrameRequirements("1 Day", "1 Week")] two timeframes will be added to the primary chart timeframe.
If OnCalculate() is called up by the primary data series, then ProcessingBarSeriesIndex will equal zero. If OnCalculate() is called up by the daily bars, then ProcessingBarSeriesIndex will equal 1. Weekly bars will have a value of 2.

Parameter

none

Usage

1
ProcessingBarSeriesIndex
Copied!

More Information

Within a script that only works with primary timeframes, the value will always equal zero.

Example

1
// To demonstrate the methodology
2
// set CalculateOnClosedBar=false
3
Print(Time[0] + " " + ProcessingBarSeriesIndex);
4
// Calculate only for the chart timeframe
5
protected override void OnCalculate()
6
{
7
if (ProcessingBarSeriesIndex > 0) return;
8
// Logic for the primary data series
9
}
Copied!