> 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.

# BarsArray

## Definition

An array holding Bars objects that are added via the [AddDataSeries()](/developer/desktop-sdk/references/common/adddataseries) method. BarsArray can be used as input for [indicator methods](/developer/desktop-sdk/references/common/system-indicator-methods). This property is of primary value when working with [multi-time frame or multi-instrument scripts](/developer/desktop-sdk/guides/educational-resources/multi-time-frame-instruments).

## Property Value

An array of [Bars](/developer/desktop-sdk/references/common/bars) objects.

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

## Syntax

`BarsArray[int index]`

## Examples

```csharp
protected override void OnStateChange()
{
    if (State == State.SetDefaults)
    {
        Name = "Examples Indicator";      
    }
    else if (State == State.Configure)
    {
        // Add a 5 minute Bars object which is added to the BarArray 
        // which will take index 1 since the primary Bars object of the strategy 
        // will be index 0 
        AddDataSeries(BarsPeriodType.Minute, 5); 
    }
} 

protected override void OnBarUpdate() 
{ 
    // Ignore bar update events for the supplementary Bars object added above 
    if (BarsInProgress == 1) 
        return; 

    // Pass in a Bars object as input for the simple moving average method 
    // Evaluates if the 20 SMA of the primary Bars is greater than 
    // the 20 SMA of the secondary Bars added above 
    if (SMA(20)[0] > SMA(BarsArray[1], 20)[0]) 
        EnterLong(); 
}
```