I have an NT 7 indicator that gives me the intermittent runtime error:
3/21/2011 6:09:47 PM Default Error on plotting values to chart data box for indicator XXX'. Please check the 'OnBarUpdate' method: Object reference not set to an instance of an object.
This occurs only when I am changing instruments or time; for example 5 min to 3 min chart.
I have stripped my code down to almost nothing and I get the error even when I have empty OnBarUpdate(); i.e.
protected override void OnBarUpdate()
{
}
I have noticed and verified the if I reapply the indicator once the new instrument or time data are loaded, I no longer get the error.
So it appears that this error results because the indicator is attempting to access data that is not yet present on the chart. Is there any way to force the indicator to wait until the new data series is loaded before executing? I am thinking of using something like
if (CurrentBar > 0)
in the OnBarUpdate() method.
Any suggestions would be greatly appreciated. Thank you.
Comment