Hello.
I am suddenly getting an error on an Indicator of mine that is so simple that there really can’t be anything wrong with it. Besides, I’ve been using it for literally months, and it’s never caused a problem.
Anyway, the error is:
Indicator ‘EntryPrice’: Error on calling ‘OnRender’ method on bar 0: 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.
And here is literally the complete code for the Indicator:
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
{ return; }
EnPriceLow = (MIN(Low, 1)[0] - leaderLead);
EnPriceHigh = (MAX(High, 1)[0] + leaderLead);
BlueLine[0] = EnPriceLow;
YellowLine[0] = EnPriceHigh;
}
How could this possibly have stopped working? It doesn’t do anything until Bar 2, so all of those values should be valid. leaderLead is just a user-entered double that sets the offset of the line from the high or low of the bar. There is nothing in here that could cause an error, especially in light of the fact that it’s been working just fine for months.
Any ideas?
Thanks in advance!