If the high is equal to the low, then double candle_height = (high-low) equals zero.
Then, double ratio = (body_height/candle_height) causes a divide by zero error
Dividing by zero is not permitted, and the code exits with "divide by zero" error..
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm trying to include the body_height/candle_height ratio to my entry conditions and MT is complaining about "zero-divide".
This is how i try ty calculate it:
double low = iLow(NULL, 0, 1);
double high = iHigh(NULL, 0, 1);
double close = iClose(NULL, 0, 1);
double open = iOpen(NULL, 0, 1);
double candle_height = (high-low);
double body_height = MathAbs(open-close);
double ratio = (body_height/candle_height);
Any ideas what I'm doing wrong here?
Thanks a lot!