![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 it's for comparison then you could easily create your own function:
It's just a thought.
If it's for comparison then you could easily create your own function:
It's just a thought.
It's a good thought, thank you for it :-)
The use of "Point" or "Point/2.0" is not a very good difference value, IMO. The roundoff error introduced by NormalizeDouble (which I got burned by today), is certainly much smaller than 8 digits, more likely 15 digits.
Given the previous tips, and made some changes and put together the following routine which seems to work fine (even using the "diff" to 15 decimal places), although it hasn't been rigorously tested yet:
Here is a check of the obvious:
Here's yet another possible routine that can compare, but can also internally normalize either A and/or B, and will also relax the comparison difference (of A-B or B-A) to a larger number based on "digits". I doubt this routine is necessary compared to the simple "AvsB" above, but it's offered for your use as desired:
The use of "Point" or "Point/2.0" is not a very good difference value, IMO. The roundoff error introduced by NormalizeDouble (which I got burned by today), is certainly much smaller than 8 digits, more likely 15 digits.
You want the biggest value that can not be considered roundoff error or equivalently, the smallest value that can not be considered a price change. Since prices can only change by a multiple of point, point/2 is just that.
The double value from the broker could be anywhere from 1.234575000000000000 through 1.23458499999999999 and still be considered the same 1.23458 price.
If you had used this, you wouldn't have had the problem:
if (a > b)
if (a >= b)
if (a != b)
should we avoid using normalisedouble ??
or may be.. i have a thought that we can use MathRound function
ex . double x= ( MathRound ( 1.37883 * 100000)) / 100000 ;
so we can make function
*Shakes his tie into position with two fingers* Only use normalize double in calculations involving a double value not just everywhere there is a double.
should we avoid using normalisedouble ??
or may be.. i have a thought that we can use MathRound function
ex . double x= ( MathRound ( 1.37883 * 100000)) / 100000 ;
You still end up with a double and still the possibility of price != price
I arrived at this solution which turns doubles into ints for the purpose of comparing doubles . . .
so that . . .
will never be true.