I have an indicator that stays on the chart for a minute or two and then goes away printing the following error message
Error on calling 'OnBarUpdate' method for indicator 'myindicator' on bar 257: Object reference not set to an instance of an object.
I have tracked it down to the following code highlighted in RED that is generating the error when dealing with several dataseries:
protectedoverridevoid OnBarUpdate()
{
if (CurrentBar < 10) return;
double YCES = Closes[1][1]; // Yesterday Close of ES
double YCYM = Closes[2][1]; // Yesterday Close of YM
The indicator will take hard values as follows and will not generate an error:
double YCES = 1000; // Yesterday Close of ES
double YCYM = 1000; // Yesterday Close of YM
So where am I going wrong or is this a true bug?
Thanks

Comment