Download MetaTrader 5
To add comments, please log in or register
Any problems with the code? Find solution in documentation!
Kieran Flynn
130
Kieran Flynn 2014.08.14 07:35 

I have written an EA in MQL4 which returns some information about the previous bar with the following lines:

double H1 = iHigh(NULL, PERIOD_H4, 1);
double L1 = iLow(NULL, PERIOD_H4, 1);
double R1 = H1 - L1;
double HC = (H1 - C1) / R1;


This works fine there is no problem.

However if I change this code to use PERIOD_H8 (as below), when executing the last line of code I receive a zero divide error:


double H1 = iHigh(NULL, PERIOD_H8, 1);
double L1 = iLow(NULL, PERIOD_H8, 1);
double R1 = H1 - L1;
double HC = (H1 - C1) / R1;


The same thing happens if I use PERIOD_H12 -

Does anybody know why this is? Is it a broker specific issue or something issue with using these particular timeframes?

Alain Verleyen
Moderator
28671
Alain Verleyen 2014.08.14 10:10  
kieranf:

I have written an EA in MQL4 which returns some information about the previous bar with the following lines:


This works fine there is no problem.

However if I change this code to use PERIOD_H8 (as below), when executing the last line of code I receive a zero divide error:



The same thing happens if I use PERIOD_H12 -

Does anybody know why this is? Is it a broker specific issue or something issue with using these particular timeframes?

There is no H8 or H12 timeframes with MT4. Only with offline charts.
Kieran Flynn
130
Kieran Flynn 2014.08.14 11:17  
Thanks!
/
To add comments, please log in or register