I am getting the following error for my very simple Indicator script:
Error on calling 'OnBarUpdate' method for indicator 'aatest' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
Did some troubleshooting, and it turns out that if I switch the Data Series option "Load data based on" to "Bars", this error disappears and my indicator works perfectly. If I switch "Load data based on" to "Days" (my preferred option), I get the above error.
I note that the error doesn't happen in "Days" mode when my code is as simple as possible. The following code works:
Print(Time[0].ToString());
The Output window is filled with a list of strings. Perfect. But the following code gives me an error on the second line:
Print(Time[0].ToString());
DrawText("test","Testing",1,Close[1],Color.Blue);
It outputs one line of DateTime, then shows the error above. It looks like I'm having some sort of problem accessing barsAgo when the chart is in "Days" mode, but not when accessing Time. "Days" mode is the default for all my charts and what I want to use. How can I fix this?
EDIT: just tried the following code:
Print(Time[1].ToString());
This error appeared in the Output box:
Error on calling 'OnBarUpdate' method for indicator 'aatest' on bar 0: Bar index needs to be greater/equal 0
Comment