Below is from the Visual Studio Immediate Window.
Trying to access 39 bars ago fails as does anything over 2.
?Close.Count
439
?BarsAgo
39
?Close[BarsAgo]
'Close[BarsAgo]' threw an exception of type 'System.NullReferenceException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147467261
HelpLink: null
InnerException: null
Message: "Object reference not set to an instance of an object."
Source: "NinjaTrader.Core"
StackTrace: " at NinjaTrader.Data.BarsSeries.GetClose(Int32 index)\r\n at NinjaTrader.Data.Bars.GetClose(Int32 index)\r\n at NinjaTrader.NinjaScript.PriceSeries.get_Item(Int32 barsAgo)"
TargetSite: {Double GetClose(Int32)}
?Close[0]
53.96
?Close[1]
53.92
?Close[2]
53.92
?Close[3]
'Close[3]' threw an exception of type 'System.NullReferenceException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147467261
HelpLink: null
InnerException: null
Message: "Object reference not set to an instance of an object."
Source: "NinjaTrader.Core"
StackTrace: " at NinjaTrader.Data.BarsSeries.GetClose(Int32 index)\r\n at NinjaTrader.Data.Bars.GetClose(Int32 index)\r\n at NinjaTrader.NinjaScript.PriceSeries.get_Item(Int32 barsAgo)"
TargetSite: {Double GetClose(Int32)}
?CurrentBar
437
Comment