I have been developing in Ninjascript for a couple of years now and am very proficient.
I am getting the error "Strategy '####': Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
Obviously I have seen this before and normally it is an easy fix.
The issue is my code is:
Values[0][0] = 1;
Values[1][0] = 2;
Called in OnBarUpdate this means that it is having trouble accessing Either the number 1 and 2 or the Values Array.
My initial thought was that I didn't have enough plots so it is having trouble assigning a value to a plot that doesn't exist. But this is my code:
AddPlot(Brushes.Orange, "MA1");
AddPlot(Brushes.Linen, "MA2");
Called in the OnStateChange method in SetDefaults State.
Could be an easy fix and I may be blind but please let me know if you see something. Cannot release code because it is proprietary but this should be all of the information you need.
Also I am well aware of print statements and have isolated those lines as the problem lines so please god don't tell me about print statements
Thanks!

Comment