BarsPeriods

View as Markdown

Definition

Holds an array of BarsPeriod objects synchronized to the number of unique Bars objects held within the parent NinjaScript object. If a NinjaScript object holds two Bars series, then BarsPeriods will hold two BarsPeriod objects.

Property Value

An array of BarsPeriod objects.

This property should NOT be accessed within the OnStateChange() method before the State has reached State.DataLoaded

Syntax

BarsPeriods[int barSeriesIndex]

Examples

1protected override void OnStateChange()
2{
3 if (State == State.Configure)
4 {
5 // Adds a 5-minute Bars object to the strategy and is automatically assigned
6 // a Bars object index of 1 since the original data the strategy is ran on,
7 // set by the UI, takes the index of 0.
8 AddDataSeries("AAPL", BarsPeriodType.Minute, 5);
9 }
10}
11
12protected override void OnBarUpdate()
13{
14 // Print out 5, the value of the secondary bars object
15 if (BarsInProgress == 1)
16 Print(BarsPeriods[1].Value);
17}