Period
Previous Topic  Next Topic 

Definition
The Bars object period type and interval.

Property Value

A Period object.


Syntax
Bars.Period.Id

Bars.Period.Value


* Id can be of value PeriodType.Tick, PeriodType.Volume, PeriodType.Second, PeriodType.Range, PeriodType.Minute, PeriodType.Day, PeriodType.Week, PeriodType.Month, PeriodType.Year

* Value will return an integer value


NOTE: We suggest using BarsPeriod property for a Strategy.

Property Of

Custom Indicator, Custom Strategy


Examples

// Calculate only if there is a 100 tick chart or greater
protected override void OnBarUpdate()
{
    if (Bars.Period.Id == PeriodType.Tick && BarsPeriod.Value >= 100)
    {
        // Indicator calculation logic here
    }
}


Additional Access Information
This property can be accessed without a null reference check in the OnBarUpdate() event handler. When the OnBarUpdate() event is triggered, there will always be a Bar object which holds the Period property. Should you wish to access this property elsewhere, check for null reference first. e.g. if (Bars != null)