"Can someone tell me why the following statement does not work?"
Because they are not equal despite your protestations.
Comparing equality of doubles is a known problem because of the way doubles are represented in binary.
When you get stuck, you can change to something like:
if(MathAbs(Bid - SellOpenPrice) < .00001)
Or...
Rosh 2007.05.16 12:13
Use function from Stdlib.mq4
//+------------------------------------------------------------------+ //| right comparison of 2 doubles | //+------------------------------------------------------------------+ bool CompareDoubles(double number1,double number2) { if(NormalizeDouble(number1-number2,8)==0) return(true); else return(false); }
phy:
Thanks Phy. I will give it try.
"Can someone tell me why the following statement does not work?"
Because they are not equal despite your protestations.
Comparing equality of doubles is a known problem because of the way doubles are represented in binary.
When you get stuck, you can change to something like:
if(MathAbs(Bid - SellOpenPrice) < .00001)
Or...
Rosh 2007.05.16 12:13
Use function from Stdlib.mq4
//+------------------------------------------------------------------+ //| right comparison of 2 doubles | //+------------------------------------------------------------------+ bool CompareDoubles(double number1,double number2) { if(NormalizeDouble(number1-number2,8)==0) return(true); else return(false); }
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
Can someone tell me why the following statement does not work?
if(Bid == SellOpenPrice)
For some reason it returns false most of the time when it is true.
Thank you in advance