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
A math teacher once told me that 0.9 recurring = 1
That has never made sense to me either.
I think he meant that when you divide 1 by 9 the answer is 0.111111111111 and as many ones as you care to type. I think a similar thing happens with floating point representation of 0.1.
Yep,
1
_ x 9 = 1 so, 1/9 = 0.111111 recurring, 0.111111 recurring x 9 = 0.9999999 recurring, hence 0.999999 recurring = 1
9
The same thing happens with 1/10. A floating point number a sum of 1/2 1/4 1/8 1/16 etc. The closest you can come to 1/10 in 24 bits is 0.100000001490116119384765625
See Floating point - Wikipedia, the free encyclopedia
May be normalizedouble can help you.
You were right, I fixed the problem like this:
Now it works properly with
20:52:51 2012.06.01 00:00 NewEA EURUSD,H1: open #1 sell 0.05 EURUSD at 1.2364 sl: 1.3372 tp: 1.2262 ok
20:52:52 2012.06.01 12:20 NewEA EURUSD,H1: Alert: Modify
20:52:52 2012.06.01 12:20 NewEA EURUSD,H1: modify #1 sell 0.05 EURUSD at 1.2364 sl: 1.2369 tp: 1.2263 ok
20:52:52 2012.06.01 16:21 Tester: stop loss #1 at 1.2369 (1.2366 / 1.2369)
I have used if(sl == openprice) before lots of times without normalizing the doubles, I didnt notice a problem then so I really dont know why it happend this time.
Having said that I don't remember using such comparison with sl and openprice+n*Point before though. I think somehow a tiny error was generated, smaller than 8dp, I tried to reveal it with DoubleToStr(value,8) but it just showed zeros after the expected 4dp price values.
Whatever it was, NormalizeDouble() must have removed it.
Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
Of course. price = 1.xxxx so MathRound(1.xxxx+0.0005) = MathRound(1.xxx5) = 1 and SL > 1 for your pair.
To round to the nearest 5 points use MathRound(value/(5*Points))*(5*Points)
To the nearest tick