How to truncate extra decimal places in mql5. NormalizeDouble not working properly....Any one can help me in this? Thanks in advance.
Please be more specific about your issue.
I can only guess that you may mean when printing of placing text in a label.
In such cases use DoubleToString().
-
Floating point has infinite number of decimals,
it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia, the free encyclopedia - Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
- SL/TP (stops) need to be normalized to tick size (not Point) — code fails on metals. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming 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 programming 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 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum
- Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
- MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
MT4:NormalizeDouble - MQL5 programming forum
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum - Prices you get from the terminal are already normalized.
Please be more specific about your issue.
I can only guess that you may mean when printing of placing text in a label.
In such cases use DoubleToString().
Hello Mr.Keith ,
Thanks for your kind reply. I have given the codes which I tried. Please help me in this if possible to you.
Thanks and regards.
RDBS.
void OnTick() { MqlTick curtick; //--- if(SymbolInfoTick(Symbol(),curtick)) { Print(curtick.time,": Bid = ",curtick.bid, " Ask = ",curtick.ask); } else Print("SymbolInfoTick() failed, error = ",GetLastError()); // THE ABOVE CODE WORKS WELL AND GIVES THE BID/ASK DETAILS FOR EUR/USD IN 5 DIGITS. // BUT THE FOLLOWING CODE GIVES 0.0 INSTEAD OF CORRECT ANSWER...... double dif = NormalizeDouble(curtick.ask,5)-NormalizeDouble(curtick.bid,5); Print("dif",dif); }
Hello Mr.Keith ,
Thanks for your kind reply. I have given the codes which I tried. Please help me in this if possible to you.
Thanks and regards.
RDBS.
Use the code button (Alt + S) when pasting code.
I have edited your post this time.
Your original question was
How to truncate extra decimal places in mql5. NormalizeDouble not working properly....Any one can help me in this? Thanks in advance.
and I answered
Please be more specific about your issue.
I can only guess that you may mean when printing of placing text in a label.
In such cases use DoubleToString().
Now you come back with code that you say is printing 0.0 and not the correct answer.
Maybe it is the correct answer because the spread is zero.
You are still not using DoubleToString().
- www.mql5.com
Use the code button (Alt + S) when pasting code.
I have edited your post this time.
Your original question was
and I answered
Now you come back with code that you say is printing 0.0 and not the correct answer.
Maybe it is the correct answer because the spread is zero.
You are still not using DoubleToString().
Thanks a lot Mr.Keith. <Deleted by moderator - Do not ask the same questions in this thread that you have opened a topic about>
Many regards.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use