Rounding numbers in MT4 via NormalizeDouble - page 15

 
pavlick_:
Some numbers can only be represented as an infinite fraction, such as 1/3 in the decimal system. But 1/3 is not an infinite fraction in the tertiary system, there it == 0.1. That is, different number systems have their own infinite fractions. Hence, a non-infinite fraction in decimal can be one in binary. For example: 0.1, 0.2, 0.3, 0.4, ... have no exact binary representation. If you call NormalizeDouble ten times, it will be either 0.19999999999...1 or 0.200000...1. I don't know, maybe this is news.

You're telling the truth! To be clear, ND is needed ONLY for comparison, not representation. And it's long since obsolete.

 
pavlick_:
Some numbers can only be represented as infinite fractions, e.g. 1/3 in the decimal system. But 1/3 is not an infinite fraction in the tertiary system, there it == 0.1. That is, different number systems have their own infinite fractions. Hence, a non-infinite fraction in decimal can be one in binary. For example: 0.1, 0.2, 0.3, 0.4, ... have no exact binary representation. If you call NormalizeDouble ten times, it will be either 0.19999999999...1 or 0.200000...1. I don't know, maybe this is news.

I remember that, but in this case it's 0+0 and it's not 0.

 
transcendreamer:

I remember that, but in this case it is 0+0 and it is not 0.

In what case? Give me an example of when this is the case.
 
fxsaber:

You're telling the truth! To be clear, ND is needed ONLY for comparison, not representation. And has long been obsolete.

NormalizeDouble is only needed to normalize price when placing pending orders and stops. It does not need it for anything else.

This is clearly stated in the documentation

The calculated StopLoss and TakeProfit values, as well as open prices of pending orders, must be normalized with the accuracy, the value of which can be obtained by Digits().

 
Sergei Vladimirov:
In what particular case? Give me an example of when this happens.

this happens when there was 0 in the variable and 0 is added to it

(I suspect it's not actually 0)

 
Slawa:

NormalizeDouble is only needed to normalise price when placing pending orders and stops. It does not need it for anything else.

This is clearly stated in the documentation

But what about comparing real numbers...
 
transcendreamer:

this happens when there was 0 in the variable and 0 is added to it

(I suspect it's not actually 0)


Exactly. The "real" zeros in addition and subtraction remain zeros. That's why I offered you an example.

 
Alexander Bereznyak:
What about comparing real numbers...

A related side effect.

It turned out to be convenient. But it was not originally intended to be used in this way.

There are special functions for printing the real number with the right accuracy.

Tell me, why do you need to round real numbers in calculations? Because in this case, the accuracy of calculations is lost!

 
Sergei Vladimirov:

Exactly. The "real" zeros in addition and subtraction are still zeros. That's why I offered you an example.

I was beginning to guess thatNormalizeDouble(new_lot-sum_lots,Lots_Digits); does not output exactly 0 and stores some tail
 
Slawa:

NormalizeDouble is only needed to normalise price when placing pending orders and stops. It does not need it for anything else.

This is clearly stated in the documentation

Obsolete

Forum on trading, automated trading systems and strategy testing

Alternative implementations of standard functions/approaches

Renat Fatkhullin, 2016.09.02 00:55

This is not the way to overload. Same function signatures.

But the idea is clear - the function of normalisation taking into account tick granulation.

Reason: