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
Amazing conclusion! What makes you think that with any digit, if you don't even "understand" what a digit is at all?
Amazing conclusion! What makes you think that with any digit, if you don't even "understand" what a digit is at all?
I should say at once that I prefer not to participate in such explanations, because if you have nothing to say on the merits, why talk at all?
I'd like to thank all the pros for their insight!
Irtron, I chose your variant, I liked it very much. I corrected it a little for general cases and checked it:
int ComparePrice(double a, double b, double digit)
{
a -= b;
b = digit;
if (a > b)
return (1);
if (a < -b)
return (-1);
return (0);
}
Thanks.
double digit14=0.00000000000001;
double digit12=0.000000000001;
double digit8=0.00000001;
double digit4=0.0001;
double digit2=0.01;
which will determine the required accuracy.
For this functionality, it works very quickly.
Irtron, thanks again.
Amazing conclusion! What makes you think that with any digit, if you don't even "understand" what digit is at all?
I should say at once that I prefer not to participate in such explanations, because if you have nothing to say on the merits, why talk at all?
Why pick on, I just read what you wrote. Your understanding is obviously hampered by "your blatant... (you name the word)"
VBAG, why reinvent the wheel when there is a function NormalizeDouble() that compares two numbers faster than ComparePrice()?
VBAG, why reinvent the wheel when there is a NormalizeDouble() function that compares two numbers faster than ComparePrice()?
If you can suggest a similar bike or better alternative solutions, I would be happy to use them.
Respectfully,
Vladimir
VBAG, why reinvent the wheel when there is a NormalizeDouble() function that compares two numbers faster than ComparePrice()?
If you can suggest a similar wheel or better alternatives, I'd be happy to use them.
Respectfully,
Vladimir
2007.09.12 07:15:09 $CheckCompareDouble USDJPY,M5: CD: 20485, xNormalize: 51265
Conclusion:
The CD function compares two double numbers , gives the answer <, > or = with 14 decimal places and works 2 times faster than simply performing NormalizeDouble()(even without logic to compare them).
Many people write that for comparing must use built-in function NormalizeDouble(). (this is what the developers recommend too).
Therefore, I would first like to define: "what is NormalizeDouble()?", i.e. how it works, what is its algorithm.
Rounding a floating point number to a specified precision.
...
I don't know how rounding is organized in MQL4 (ask the developers), but I know a standard method Rounding floating point numbers to specified precision:
Here, a function:
From this function you can see that we first go from a real number to an integer, and then back to a real number again.
For comparison, it is enough to go to an integer only.
Therefore, I believe the fastest and most reliable way to compare real numbers is to convert them to integers.
This is what the comparison will look like:
All this can be formatted into a function and used. It's a pain to write, it seems to be clear how to make a function!
I think this way is faster than calling NormalizeDouble().
To be safe, you can also make MathRound() function return an integer, since by default it returns double.
The easiest way to do it this way
Then only integers will be compared, and they compare well!
I think this way is the most correct, don't you?
So I think the quickest and most reliable way is to convert the real numbers to integers
The comparison would look like this:
I think that's the right way to do it, don't you?
The whole beauty of Irtron's code is in its compactness (absolutely nothing extra - even variables are saved!).
And you suggest we should add two more operations for every operation at least.
That's a speed advantage!
I don't think so. Judge for yourself