hi,
this is a part of my indi but it does not work. when I delete the division, it works! I will appreciate if you could help me to solve the problem.
double A1,A2,A3;
A1=iClose("EURUSD", PERIOD_CURRENT, i);
A2=iClose("GBPUSD", PERIOD_CURRENT, i);
A3 =(1/A1+1/A2);
double A1,A2,A3; A1=iClose("EURUSD", PERIOD_CURRENT, i); A2=iClose("GBPUSD", PERIOD_CURRENT, i); if(A1>0 && A2>0) A3 =(1/A1+1/A2);
Hi,
I have tested the code and the division works fine when A1 and A2 have valid values.
So you should check if A1 and A2 are greater 0 (as Mehmet Bastem suggested) and check
the results of the iClose function.
Best regards
Hi,
I advise you to check the values of A1 and A2 with a print statement and change the code
as Mehment suggested:
if(A1>0 && A2>0) A3 =(1/A1+1/A2);
or
if(A1>0 && A2>0) A3 =((1/A1) + (1/A2));
The division shouldn't be a problem for the Metatrader - I do more complex calculations with MQL4 without any problems.
Best regards
Hi,
I advise you to check the values of A1 and A2 with a print statement and change the code
as Mehment suggested:
or
The division shouldn't be a problem for the Metatrader - I do more complex calculations with MQL4 without any problems.
Best regards
A1=iClose("EURUSD", PERIOD_CURRENT, i); A2=iClose("GBPUSD", PERIOD_CURRENT, i);
-
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. To avoid getting zero.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20 -
Same index for both symbols. You must check each symbol for its bar count. To avoid getting zero.
-
Do not assume an index on the current chart is the same as on other charts. Always use iBarShift.
-
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. To avoid getting zero.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20 -
Same index for both symbols. You must check each symbol for its bar count. To avoid getting zero.
-
Do not assume an index on the current chart is the same as on other charts. Always use iBarShift.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi,
this is a part of my indi but it does not work. when I delete the division, it works! I will appreciate if you could help me to solve the problem.
double A1,A2,A3;
A1=iClose("EURUSD", PERIOD_CURRENT, i);
A2=iClose("GBPUSD", PERIOD_CURRENT, i);
A3 =(1/A1+1/A2);