NinjaScript > Language Reference > Data >


Print this Topic Previous pageReturn to chapter overviewNext page


Holds an array of int values representing the number of the current bar in a Bars object. An int value is added to this array when calling the Add() method in a Custom Indicator/Strategy. Its purpose is to provide access to the CurrentBar of all Bars objects in a multi-instrument or multi-time frame indicator/strategy.


Property Value

An array of int values.



CurrentBars[int barSeriesIndex]




protected override void Initialize()
    // Adds a 5-minute Bars object to the script. It will automatically be assigned
    // a Bars object index of 1 since the primary data the indicator is run against
    // set by the UI takes the index of 0.
    Add(Instrument, PeriodType.Minute, 5);

protected override void OnBarUpdate()
    // Checks to make sure we have at least 20 (default value of BarsRequired)

    // or more bars in both Bars objects before continuing.
    if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
    // Script logic calculation code...