Bug in your code. You NEED to initialize the buffers.
Do I do this with the int ArrayInitialize( double array[],double value); method?
And if yes at which point? After the SetIndexBuffer call in OnInit()?
Do I do this with the int ArrayInitialize(double array[],double value); method?
And if yes at which point? After the SetIndexBuffer call in OnInit()?
No. In OnCalculate(), when prev_calculated=0
Hi @Alain Verleyen.
I see that in CCI.mq5 indicator that is shipped with MQL5, they don't initialize the buffers, yet the indicator works. Why is that?
Hi @Alain Verleyen.
I see that in CCI.mq5 indicator that is shipped with MQL5, they don't initialize the buffers, yet the indicator works. Why is that?
Do I do this with the int ArrayInitialize( double array[],double value); method?
And if yes at which point? After the SetIndexBuffer call in OnInit()?
Yes.
No. In OnCalculate(), when prev_calculated=0
Thanks for the solution. It was creating huge problem.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have encountered some strange behavior with initiating an indicator. Setting the PLOT_EMPTY_VALUE to 0 does not seem to work properly, with values other than 0 appearing in the data window.
I have made the following indicator to test different empty value setting ways:
And the plot I get is this:
The spikes are indicative of the indicator lines not zeroing out. The spikes can be different between consecutive compilations of the indicator(without changing anything in the code).
The only way that seems to work is the last one with the use of a double variable.
Is this a bug or is there any other way to properly set the empty value for an indicator buffer?