> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# CurrentBars

## Definition

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 **[AddDataSeries()](/developer/desktop-sdk/references/common/adddataseries)** method. Its purpose is to provide access to the **[CurrentBar](/developer/desktop-sdk/references/common/onbarupdate/currentbar)** of all Bars objects in a multi-instrument or multi-time frame script.

In **[multi series](/developer/desktop-sdk/guides/educational-resources/multi-time-frame-instruments)** processing, the CurrentBars starting value will be -1 until all series have processed the first bar.

## Property Value

An array of int values.

Warning: This property should NOT be accessed within the **[OnStateChange()](/developer/desktop-sdk/references/common/onstatechange)** method before the State has reached State.DataLoaded.

## Syntax

`CurrentBars[int barSeriesIndex]`

## Examples

### Indicator (**[BarsRequiredToPlot](/developer/desktop-sdk/references/indicator/barsrequiredtoplot)**)

```csharp
protected override void OnStateChange()
{
     if (State == State.Configure)
     {
         // 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.
         AddDataSeries("AAPL", BarsPeriodType.Minute, 5);
     }
}

protected override void OnBarUpdate()
{
     // Evaluates to make sure we have at least 20 (default value of BarsRequiredToPlot)
     // or more bars in both Bars objects before continuing.
     if (CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot)
         return;

     // Indicator script logic calculation code...

}
```

### Strategy (**[BarsRequiredToTrade](/developer/desktop-sdk/references/strategy/barsrequiredtotrade)**)

```csharp
protected override void OnStateChange()
{
     if (State == State.Configure)
     {
         // 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.
         AddDataSeries("AAPL", BarsPeriodType.Minute, 5);
     }
}

protected override void OnBarUpdate()
{
     // Evaluates to make sure we have at least 20 (default value of BarsRequiredToTrade)
     // or more bars in both Bars objects before continuing.
     if (CurrentBars[0] < BarsRequiredToTrade || CurrentBars[1] < BarsRequiredToTrade)
         return;

     // Strategy script logic calculation code...
}
```