small problem with computing daily movement (divide problem)

 

Hello, 


I have a small but really frustrating problem with dividing. The Indi has many-many arrays and works well, but now I wanted to change the base of the arrays. The old one was the RSI, now i want to change into Daily % change ( or candle, because I want to see it on every TF).

So, I wanted to type in that  ( Close-Open ) / Close *100 .

Till Close-Open everything works fine, the MT4 computes all the datas. But right after I put a "/" mark into  the line, everything goes wrong, all the arrays are empty, however the basic stuff is computed because I see the right datas on the last 15 bars. No visual as well (it has to). I don't understand. Can you help me? 

Oh I tried two different methods as you see but no result...

Thanks

wicha

ps. RSI here is simply =1 to get the bar's value

double GetSlope(string symbol, int tf, int shift)

{
   double close= iMA(symbol,tf,RSI,0,MODE_SMA,PRICE_CLOSE,shift);
   double close2= iClose(symbol,tf,shift);
   double open = iOpen(symbol,tf,shift);
   double range = close-open;
   
   double gadblSlope =(range/close2)*100;

   
   return ( gadblSlope );
   
}  
 
csibiri_cse:

Hello, 


I have a small but really frustrating problem with dividing. The Indi has many-many arrays and works well, but now I wanted to change the base of the arrays. The old one was the RSI, now i want to change into Daily % change ( or candle, because I want to see it on every TF).

So, I wanted to type in that  ( Close-Open ) / Close *100 .

Till Close-Open everything works fine, the MT4 computes all the datas. But right after I put a "/" mark into  the line, everything goes wrong, all the arrays are empty, however the basic stuff is computed because I see the right datas on the last 15 bars. No visual as well (it has to). I don't understand. Can you help me? 

Oh I tried two different methods as you see but no result...

Thanks

wicha

ps. RSI here is simply =1 to get the bar's value

Your code does not compute daily/candle % change correctly, but I doubt that would result in "all the arrays are empty"... show more complete code if you haven't figure out why...

 
csibiri_cse:

Hello, 


I have a small but really frustrating problem with dividing. The Indi has many-many arrays and works well, but now I wanted to change the base of the arrays. The old one was the RSI, now i want to change into Daily % change ( or candle, because I want to see it on every TF).

So, I wanted to type in that  ( Close-Open ) / Close *100 .

Till Close-Open everything works fine, the MT4 computes all the datas. But right after I put a "/" mark into  the line, everything goes wrong, all the arrays are empty, however the basic stuff is computed because I see the right datas on the last 15 bars. No visual as well (it has to). I don't understand. Can you help me? 

Oh I tried two different methods as you see but no result...

Thanks

wicha

ps. RSI here is simply =1 to get the bar's value

Hello,

try this option.

double gadblSlope =0;
if(close2!=0) gadblSlope =(range/close2)*100;
 
Nikolaos Pantzos:

Hello,

try this option.

if (fabs(close2) > 0) rather. (On MT5)

 
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4
Reason: