BarsInProgress

View as Markdown

Definition

An index value of the current Bars object that has called the OnBarUpdate method. In a multi-bars script, the OnBarUpdate() method is called for each Bars object of a script. This flexibility allows you to separate trading logic from different bar events.

  1. In a single Bars script this property will always return an index value of 0 representing the primary Bars and instrument the script is running on.
  2. See additional information on running multi-bars scripts.

Property Value

An int value represents the Bars object that is calling the OnBarUpdate() method.

Syntax

BarsInProgress

Examples

1protected override void OnStateChange()
2{
3 if (State == State.Configure)
4 {
5 // Add a 5 minute Bars object: BarsInProgress index = 1
6 AddDataSeries(BarsPeriodType.Minute, 5);
7 }
8}
9
10protected override void OnBarUpdate()
11{
12 // Check which Bars object is calling the OnBarUpdate() method
13 if (BarsInProgress == 0)
14 {
15 // A value of zero represents the primary Bars which is the ES 09-14
16 // 1 minute chart.
17 // Do something within the context of the 1 minute Bars here
18 }
19 else if (BarsInProgress == 1)
20 {
21 // A value of 1 represents the secondary 5 minute bars added in OnStateChange() State.Configure
22 // Do something within the context of the 5 minute Bars
23 }
24}