2023-09-06 12:02:54:229 ERROR: Failed to call 'Add' method: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource) at NinjaTrader.Gui.Chart.MultiEquidistant.GetTimeBySl otIndex(Int32 slotIndex) at NinjaTrader.Gui.Chart.ChartBars.MultiEqSaveTimes(M ultiEquidistant equidistantMulti, DateTime fromTime) at NinjaTrader.Gui.Chart.MultiEquidistant.UpdateBar2S lotMappings(BarsSeries barsSeries, Int32 minBarIndex, Int32 maxBarIndex) at NinjaTrader.Gui.Chart.ChartControl.OnBarsUpdate(Ob ject sender, BarsUpdateEventArgs e) at NinjaTrader.Data.BarsSeries.Add(Bars bars, Double open, Double high, Double low, Double close, DateTime time, Int64 volume, Double tickSize, Boolean isBar, Double bid, Double ask)
2023-09-06 12:02:55:194 Gui.Chart.ChartPanel.OnRender: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource)
at NinjaTrader.Gui.Chart.MultiEquidistant.GetTimeBySl otIndex(Int32 slotIndex)
at NinjaTrader.Gui.Chart.MultiEquidistant.UpdateX2Tim eMapping(Int32 firstSlotPainted, Int32 lastSlotPainted)
at NinjaTrader.Gui.Chart.Direct2DForm.RenderInit()
2023-09-06 12:02:55:194 ERROR: Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index'
2023-09-06 12:02:56:192 Gui.Chart.ChartPanel.OnRender: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource)
at NinjaTrader.Gui.Chart.MultiEquidistant.GetTimeBySl otIndex(Int32 slotIndex)
at NinjaTrader.Gui.Chart.MultiEquidistant.UpdateX2Tim eMapping(Int32 firstSlotPainted, Int32 lastSlotPainted)
at NinjaTrader.Gui.Chart.Direct2DForm.RenderInit()
I had 2 different BarsTypes on the chart (2 data Series, same instrument).
The log error doesn't explicitly say "AddBar()", just Add() method...
I might still be hungover from Labor Day, but I came up with an illusion that this might be happening because the BarsType which was trying to add a new bar, was trying to use an Index value which did not exist yet in the overall BarArray index. And tha caused the Bar OnRender method (happening behind the scenes, not in my BarsType script), to toss the error.
I avoided this error, when I made the barstype with the higher resolution as the first barstype, i.e. BarsArray 0, i.e. moving that BarsType to the top of the Data Series list in the Config Box, then this error did not happen again.
I post this with the intention of helping others track down this error and possible solutions.
Comment