Error: I get EMPTY_VALUE from indicator. How to fix it

 
Hi Guys,

When I try to create Bar indicator based on other indicator I can not get the value for the first not completed Bar. I have got EMPTY_VALUE. In order to skip that I decided to use the value of the first completed bar of the based indicator (limit+1) and to use it as Bar[0] in my indicator. That works but I still receive EMPTY_VALUEs. I set the Alert notification to see the values and my MT4 terminal went in cycle.
I have added the codes for the two indicators. My indicator is FX indi.

I will much appreciate if you take a look and solve that issues.

Thank you in advance.


 
elo15: Error: I get EMPTY_VALUE from indicator. How to fix it
You picture shows a colored (BLUE/RED) indicator. Therefor one buffer is set and the other is EMPTY_VALUE. Figure out which buffer corresponds to which color.
 
WHRoeder:
You picture shows a colored (BLUE/RED) indicator. Therefor one buffer is set and the other is EMPTY_VALUE. Figure out which buffer corresponds to which color.


Hi, the issue is not in the buffers corresponding to the both colors. I have the code:

//***
 value1 = iCustom(NULL,PERIOD_M15,"G8_USD",1,10,60,0,limit+1);
 value2 = iCustom(NULL,PERIOD_M15,"G8_USD",1,10,60,6,limit+1);
//***
      if(value1>value2) {
         aUP_Buffer[limit] = 1;
         aDOWN_Buffer[limit] = 0;
      }
      if(value1<=value2) {
         aUP_Buffer[limit] = 0;
         aDOWN_Buffer[limit] = 1;
      }
      if ((value1==EMPTY_VALUE)||(value2==EMPTY_VALUE)){
         aUP_Buffer[limit] = aUP_Buffer[limit+1];
         aDOWN_Buffer[limit] = aDOWN_Buffer[limit+1];
       
         Alert("Default value for (value1==EMPTY_VALUE)||(value2==EMPTY_VALUE)");
      }
//***

I have used "limit+1" (for iCustom function) because when I use only "limit" in case limit==0 and the new bar is just formed, I get EMPTY_VALUEs for value1 and value2.

Note: I do not get EMPTY_VALUE when I attach or re-compile the indicator.

For example: using the code below:

   double Ed = iCustom(NULL,PERIOD_M15,"G8_USD",1,10,60,0,limit); 
   double Ud = iCustom(NULL,PERIOD_M15,"G8_USD",1,10,60,6,limit);

   // This Alert is to check the velues
   Alert("limit=",limit," EUR 0 = ",Ed," USD 0 =",Ud);

I got the result when the new Bar has just formed:

Is it possible to get real value in case limit==0 and after the new bar has formed ?

 
elo15:

Note: I do not get EMPTY_VALUE when I attach or re-compile the indicator.

Is it possible to get real value in case limit==0 and after the new bar has formed ?
  1. Then your indicator is broken. Post the code.
  2. Define 'real value'. On a new tick value(0) is the indicator with OHLC all the same, the first tick. Does that have any real meaning?
  3.  value1 = iCustom(NULL,PERIOD_M15,"G8_USD",1,10,60,0,limit+1);
     value2 = iCustom(NULL,PERIOD_M15,"G8_USD",1,10,60,6,limit+1);
    
    I doubt one color is buffer 0 and the other is 6, since you don't display any other lines for [1-5]. Post the code or see Detailed explanation of iCustom - MQL4 forum


 
WHRoeder:
  1. Then your indicator is broken. Post the code.
  2. Define 'real value'. On a new tick value(0) is the indicator with OHLC all the same, the first tick. Does that have any real meaning?
  3. I doubt one color is buffer 0 and the other is 6, since you don't display any other lines for [1-5]. Post the code or see Detailed explanation of iCustom - MQL4 forum



My replies:

1) I have attached the code for both indicators in my first post in zip file.

2) I can not understand your idea. I tried to set waiting time just to see if after a while the value(0) will be real number, but with no success.

3) One color Blue is when value1>value2, the other Red when value1<=value2. And the lines for [1-5] are for other fx pairs /you can see from the code/.

 
elo15:


My replies:

1) I have attached the code for both indicators in my first post in zip file.

2) I can not understand your idea. I tried to set waiting time just to see if after a while the value(0) will be real number, but with no success.

3) One color Blue is when value1>value2, the other Red when value1<=value2. And the lines for [1-5] are for other fx pairs /you can see from the code/.


as "real value" I meant in case limit==0 then value1=-0.8447 at 11:00 EEST, when the new bar was appear.

I expect "value1=-0.8447" on the first tick /which number will be different for each call of the function until the tick has fully formed./

 
elo15:


as "real value" I meant in case limit==0 then value1=-0.8447 at 11:00 EEST, when the new bar was appear.

I expect "value1=-0.8447" on the first tick /which number will be different for each call of the function until the tick has fully formed./


Thank you, WHRoeder, after your advise I managed to locate and fix the issue.

Reason: