Normalize double error
Why this is happening?
http://screencast.com/t/IVUWE3n2
I use the next codeline but some values are correct and others not, why it could be?
It's to do with how the values get stored in binary. There has been a rather protracted discussion about this on another thread yesterday.
For example, you might think you can store 0.1 exactly. Unfortunately, you can't.
printf("%.20f",value);
Result: 0.10000000000000000555
The solution is to accept that many numbers don't have a finite representation in binary and just control the output when you want to display the number e.g.
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
LoL guys you have been very helpfull!
Thanks a lot.
Why this is happening?
http://screencast.com/t/IVUWE3n2
I use the next codeline but some values are correct and others not, why it could be?