Questions from Beginners MQL5 MT5 MetaTrader 5 - page 474

 
Alexey Viktorov:
That's not all... https://www.mql5.com/ru/forum/66827
Strange nice man... Oh, well...
 
How do I know the real value of a variable of type double? The point is that sometimes thousandths are thrown out by print - the variable itself is formed from a text string, but it goes through a rounding procedure.
 
-Aleks-:
How do I know the real value of a variable of type double? The thing is, sometimes thousands of digits are thrown out via print - the variable itself is formed from a text string, but it goes through a rounding procedure.
Ahem. What do you need it for?
 
Alexey Kozitsyn:
Ahem. What do you need it for?
To detect an error in calculations :)
 
-Aleks-:
To detect an error in the calculation :)
Do you want to compare multiple values of type double?
 
Alexey Kozitsyn:
Do you want to compare several values of type double?
Not really... there is an assumption that numbers do not always have an integer value of 4=3.9999999999999999999 and an inaccuracy is formed after mathematical operations after rounding.
 

Can you please send e-mail messages from the Metatrader 4 terminal in such a way that a screenshot of the current chart is taken and put in the middle of the message. Example:

There was a buy signal on EurUsd

<скриншот09122015_eurusd.png>

Additional information about the opening.

Tell me how to implement this? Maybe there is an example or something similar that can be redone. Thanks!
 
-Aleks-:
Not quite... there is an assumption that numbers do not always have an integer value of 4=3.99999999999999999 and after doing the math, you get an inaccuracy after rounding.

Even if inaccuracy appears, use NormalizeDouble(). Set the accuracy you want for your calculations. This is what this function is for.

The example there seems to describe your case:

You should be aware that the normalised number when output to the Journal using Print() may contain more decimal places than you expect. For example,

DoubleToString(a,8)=76.67100000

Print(76.671)=76.67100000000001

 
Alexey Kozitsyn:

Even if inaccuracy appears, use NormalizeDouble(). Set the accuracy you want for your calculations. This is what this function is for.

The example there seems to describe your case:

Yes - described, yes - I use it - the question is just how not through Print and in general string to get data for analysis :)
 
-Aleks-:
Yes - it is described, yes - I use it - the question is how not through Print and string in general to get data for analysis :)

Using the same NormalizeDouble(). You get a number of type double. Normalized. Simply Print() outputs it like this.

Here it is written how to do the comparison correctly: https://www.mql5.com/ru/docs/basis/types/double

Документация по MQL5: Основы языка / Типы данных / Вещественные типы (double, float)
Документация по MQL5: Основы языка / Типы данных / Вещественные типы (double, float)
  • www.mql5.com
Основы языка / Типы данных / Вещественные типы (double, float) - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
Reason: