NinjaScript > Language Reference > Strategy >

BarsRequired

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

The number of historical bars required before the strategy starts processing calls to the OnBarUpdate() method. This property is generally set via the UI when starting a strategy.

 

The OnBarUpdate() method is not triggered until CurrentBar >= BarsRequired. In a multi-series strategy this restriction applies only for the primary Bars object. Should your strategy logic intertwine calculations across different Bars objects please ensure all Bars objects have met the BarsRequired requirement before proceeding. This can be done via checks on the CurrentBars array.

 

Property Value

An int value representing the number of historical bars.

 

Syntax

BarsRequired

 

 

Examples

protected override void Initialize()
{
    BarsRequired = 20;
}

 

Tips

1.When working with a multi-series strategy, real-time bar update events for a particular Bars object are only received when that Bars object has satisfied the BarsRequired requirement. To ensure this requirement is met, please use the CurrentBars array.