Bug in MetaEditor Build 3566: Wrong display of double floating point numbers in the debugger window - page 4
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
If you are interested, you could retest your example with the function MathRound(value, digits) from my library math_utils. It rounds exactly without any tiny round off errors.
Edit 2:
Try a dialog box that uses a float type to see what I mean.
Edit 3:
The function DoubleToString(value, digits) also has some issue, that's the direction of rounding applied to half-way decimal numbers is not consistent and cannot be predicted:
The main task of a financial application when working with prices is a single price normalization algorithm. If all prices are normalized according to a single algorithm, then everything is in order. The link is proof that this is exactly what happens in the MT5.
Exactly, this is a proof that prices are rounded by NormalizeDouble(). But, it is not a proof that NormalzieDouble() itself is correct.
For example, if I code the function round(num, digits) to round numbers. If the last decimal place is 3 or below, it gets rounded to 0. If it is 4 and above, it gets rounded to 1.
Surely, using round(1.4, 1) => 2.0 as you proved it, but do you think this is the correct way to round?
The issue here, why prices gets rounded as long as it is supposed to be received in the raw state from the inter-bank network. Do they also have NomralizeDouble function, there?
Edit:
I did not check before how cTrader or other tarding platforms receive their raw quote prices.
it is not a proof that NormalzieDouble() itself is correct.
If this word is removed from the description of the function, then it becomes correct for its use.
NormalizeDouble
Rounding floating point number to a specified accuracy.
If this word is removed from the description of the function, then it becomes correct for its use.
Even the word normalize have a specific meaning in the context of fp, other than what the function means. It specifically means unifying the exponents when adding or subtracting two fp numbers. Google floating point arithmetic in IEEE 754.
The real algorithms for a correct shortest toString() function are complex. You can check the codes at https://github.com/abolz/Drachennest/tree/master/src
For a proof of the correctness of NormalizeDouble(), you can run this script to compare how it performs against the Decimal.Round() Method from the Microsoft .Net Framework library. The Decimal value type (128-bits) is appropriate for financial calculations that require large numbers of significant integral and fractional digits and no round-off errors. https://learn.microsoft.com/en-us/dotnet/api/system.decimal.round?view=net-7.0
Please install "Ron's CSV Editor" on your computer to open files\rounding_errors.csv automatically. It is free. https://www.ronsplace.ca/Products/RonsEditor/DownloadIn this MT4, the function works the way you want. But there must be a balance between accuracy and execution speed.
If all prices are normalized according to a single algorithm, albeit not an ideal one, then the normalization task for comparing prices is 100% complete.
In this MT4, the function works the way you want. But there must be a balance between accuracy and execution speed.
If all prices are normalized according to a single algorithm, albeit not an ideal one, then the normalization task for comparing prices is 100% complete.
So, do not complain!
So, do not complain!
This is not a complaint, but a warning that normalization is not exactly what most users think.