BarPeriods
Previous Topic  Next Topic 

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 BarPeriods will hold two Period objects.


Property Value

An array of Periods objects.


Syntax
BarPeriods[int barSeriesIndex]


Property Of

Custom Strategy


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(BarPeriods[1].Value);
}