
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
VBAG take a look at this script
price = 1.1111
ma = 1.11110001
When normalised to 8 digits ma>price is correct. Normalizing to fewer digits will result in equal - incorrect. This is how maximum accuracy is achieved.
In general, without normalising ma > price is also the right thing to do. Why achieve maximum accuracy when it is already there, and already known to be greater than achievable?
Normalizing to 9 digits does not work. The impression is that the price is sort of 9 digits and the indictor has 8 or vice versa (I do not remember), in short it is covered by the mystery of the unknown.
Yes, most likely, it's in NormalizeDouble itself only counts up to 8 digits. I'm telling you, it's a ridiculous function, no matter how you spin it.
And in simplified form it works as fast as ComparePrice:
And in its original form, it's just a song :)
Or is ComparePrice also suitable for comparing any numbers with any given accuracy?
Or is ComparePrice also suitable for comparing any numbers with any given accuracy?
Of course! If the accuracy is known, which is the case with trading values. Fixed point.
Only it is necessary to explain it to numerous authors of topics "about comparison of doubles".
That is why I proposed a _universal_ (but far from optimal) way of comparing.
And it works. Slowly but reliably. And in all the cases.
And when a topic "About optimization of comparison of doubles" appears we will be able to develop it ;)
Is price normalisation needed anywhere?
It is written in the documentation that prices in trade requests must be normalised.
In the 'Unnormalized History and Opening Positions' branch, it says the following:
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.
Digit=0 will cause problems.
Any digit will cause problems. I don't understand what digit is and what is the point of modification.
Also the function is slower than a single call toNormalizeDouble().
What's the topic of comparing functions with different functionality? One simplified (unworkable, though), now it's NormalizeDouble.
What and to whom do you want to prove with such a blatant... (insert word yourself)?