OnRender error - from nowhere

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!

I’m taking a wild guess that it’s something in OnRender.

I noticed that, myself. Normally, that error shows up in OnBarUpdate. But, since I have no direct calls to OnRender in the code, I wasn’t sure how to investigate that.

You have to post the full code

You don’t need to. It’s probably being run from your plot series. NT render cycle is probably happening before enough chart bars are loaded. Just set your default to BarsRequiredToPlot = 2;.

Okay, the BarsRequiredToPlot solution did not work, but I figured it out…kind of.

It had something to do with the fact that the market was closed on Friday. I was running Playback from Monday, with my “Days to load” set to 3. When I changed it to 4, no problem.

So, I guess I just have to make sure that the oldest day in the historical data I’m asking it to load is a market open day. It seems odd that I haven’t run into this before, but it’s a simple enough workaround.

Thanks guys!