Features of the mql5 language, subtleties and tricks - page 143

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
You just shouldn't expect that if there is no value, it's necessarily 0 and correspondingly false if it's not a bool-type variable. Even an explicit conversion to bool will not help.
It works this way without errors.
I honestly don't understand where zero comes from at all:
TickValue[0] contains rubbish. It may or may not equal zero.
If trash in TickValue[0] is not equal to zero, then we calculate Points = Profit / Lots * non-zero trash * _Point, otherwise, if trash in TickValue[0] is equal to zero - we equate Points to zero.
And where does the expression Lots * non-zero rubbish * _Point get zero from, if Lots is initialized with one when declared? Isthere zero in _Point?
The error is clear in fact.
OK, the error is unclear. And it's not reproducing for me either.
Ok, the error is incomprehensible. And it doesn't reproduce at me.
Roughly speaking, calling this function may cause division by zero.
I encountered this problem in practice in the Report library. Then I realized that it's logical.
Roughly speaking, calling this function can cause division by zero.
I have this code on border dubles, but it does not crash
I get the same code on border dubles, but it doesn't crash
such a crash.
To summarise, multiplying two non-zero doublets can give zero. And this is not some degenerate case, but a real one in practice.
Roughly speaking, a combat EA can break because of this with far from zero probability.
And checking for zero will not save, either explicitly or implicitly (bool conversion)
To summarise, multiplying two non-zero doublets can give zero. And this is not some degenerate case, but a real one in practice.
Roughly speaking, a combat EA can break because of this with far from zero probability.
on NaN you need to check additionally, most likely this code will workhttp://qaru.site/questions/20557/checking-if-a-double-or-float-is-nan-in-c
or limit the accuracy, as in CompareDoubles() example - it seems to be in SBhttps://www.mql5.com/ru/docs/basis/types/double