NinjaScript > Language Reference > Data >

BarsPeriods

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

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

 

NOTE: This property should NOT be accessed within the Initialize() method.

 

Property Value

An array of Periods objects.

 
Syntax
BarsPeriods[int barSeriesIndex]

 

 

Examples

protected override void Initialize()
{
    // Adds a 5-minute Bars object to the strategy and is automatically assigned
    // a Bars object index of 1 since the primary data the strategy is run against
    // set by the UI takes the index of 0.
    Add(Instrument, PeriodType.Minute, 5);
}
 
protected override void OnBarUpdate()
{
    // Print out 5, the value of the secondary bars object
    if (BarsInProgress == 1)
         Print(BarsPeriods[1].Value);
}