Error : zero divide : Why ?

 

Hello

I have a pb that i can't solve :

double ab =iMA("EURUSD",0,1,0,MODE_SMA,PRICE_CLOSE,pos);
double bc =iMA("USDCHF",0,1,0,MODE_SMA,PRICE_CLOSE,pos);
      
double ca = 1/(ab*bc);

ab is correct (i can see it in a buffer), bc is correct too but 1/(ab*ac) return an error !

Can you explain me wghy ?

 
rookypipskiller:

Hello

I have a pb that i can't solve :

ab is correct (i can see it in a buffer), bc is correct too but 1/(ab*ac) return an error !

Can you explain me wghy ?

How do you know that bc is correct?

Where is pos assigned a value?

Is this on a live chart or the tester?

 

I think ab of bc is zero sometimes but not all the time.


might be a reason why

 
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
 
Thank you, there must be an error while reading a candle.
The pos value is the number of the candle in the loop that reads the candles ...
 
rookypipskiller:
Thank you, there must be an error while reading a candle.
The pos value is the number of the candle in the loop that reads the candles ...
you need to check for missing candle history, see post #3
 
rookypipskiller: The pos value is the number of the candle in the loop that reads the candles ...

You are assuming that both symbols have the same index and bar count.
          Don't mix apples and oranges.

Reason: