Quick question about default buffer values

 

Hi all,


When I initialize a buffer using SetIndexBuffer(), is the buffer contents filled with EMPTY_VALUE? Reason for that is I want to check if there is a value at [1] or if it is empty.


Thanks

 

By default buffers are filled with EMPTY_VALUE and no values are displayed into the "data window".

Anyway in some indicators (especially on old indicators and in my opinion also not correctly done) people like to use 0 for EMPTY_VALUE on buffer and then this command is used for displaying no value into "data windows" when buffer value is 0.

PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);

Honestly no reasons comes to my mind for choosing a way or another, so better to use the default behavior that is EMPTY_VALUE by default.

So replying to your question: yes!

Don't forgot to do ArrayInitialize when prev_calculated is less than 1 (at the first indicator OnCalculate call).

 
Fabio Cavalloni #:

By default buffers are filled with EMPTY_VALUE and no values are displayed into the "data window".

Anyway in some indicators (especially on old indicators and in my opinion also not correctly done) people like to use 0 for EMPTY_VALUE on buffer and then this command is used for displaying no value into "data windows" when buffer value is 0.

Honestly no reasons comes to my mind for choosing a way or another, so better to use the default behavior that is EMPTY_VALUE by default.

So replying to your question: yes!

Don't forgot to do ArrayInitialize when prev_calculated is less than 1 (at the first indicator OnCalculate call).

Thank you very much!

 

Fabio Cavalloni #:

PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);

You probably missed that this is in the MQL4 section (easily done) and that is MQL5 code.

 
Keith Watford #:

You probably missed that this is in the MQL4 section (easily done) and that is MQL5 code.

You are right, unfortunately on the home page of mql there are no information about the section of the thread, and also in the thread itself.

 
Fabio Cavalloni #: You are right, unfortunately on the home page of mql there are no information about the section of the thread, and also in the thread itself.

Just over the up arrow at the top or bottom of the thread and look at the URL up arrow

 
Fabio Cavalloni #: ... and also in the thread itself.


Hover your mouse over the arrow as William pointed out.

 
This is totally new for me! Thanks.
Every time something new that need to be learnt.
Reason: