Errors, bugs, questions - page 1782

 
-Aleks-:

Which ones work?

The rule of losing significant digits and filling them with random works

The result is long, but in the intermediate calculations of double and that is where significant digits are lost

(Digits+1)*3-1=17

 
A100:

The rule of losing significant digits and filling them with random works

The result is long, but in the intermediate calculations of double and that is where significant digits are lost

(Digits+1)*3-1=17

Thank you for the information.

However, the information is hard to grasp - i.e. the number can be so, but you can't do calculations with it?

Here is an example of code where it is converted from string to number

long CalcY=StringToDouble("111111111111111111");
Print ("CalcY=",CalcY);

Prints the number 111111111111111104.

I.e. there are no calculations here or am I wrong?

Is it possible to handle these numbers or are these language limitations?

 
-Aleks-:

So there are no calculations here, or am I wrong?

A calculation is any operation (in thiscase a conversion). For the specified number StringToDouble returns double with loss of precision

StringToInteger returns long, but further functions operating with double cannot be used in calculations without loss of precision such as NormalizeDouble, MathPow

 
A100:

Computation - any operation (in this case a conversion). StringToDouble returns double - there is a loss of precision

StringToInteger returns long, but further functions operating with double cannot be used in calculations without loss of precision, such as NormalizeDouble, MathPow,

StringToInteger worked to express the number, but then it gets worse, I guess the number must be broken down into its components for mathematical operations...

long CalcZ=StringToInteger("111111111111111111");
Print ("CalcZ=",CalcZ);

double Test=CalcZ;
Print ("Test=",Test);

Test=1.111111111111111e+17

 

Again, it is written in the helpdesk

INT_MAX

Maximum value that can be represented by int type

2147483647

Then how did StringToInteger perform the conversion and store it in long if the number is larger than allowed?

 
-Aleks-:

Then how did StringToInteger convert and store to long if the number is larger than allowed?

StringToInteger originally returns long withinLONG_MINLONG_MAX(it could also be called StringToColobok)

 
A100:
StringToInteger originally returns long (it might as well have been called StringToBoob)

Of course, this is probably true, but in the help it is so muddled

"

Converts a string containing a character representation of a number to an int (integer) number.

"

That's what misled me.

Thanks for the information.

I take it that the above number representation will not fit into the graphical buffer?

 
-Aleks-:

I take it that the above number will not fit in the graphical buffer?

They are written as B'11111111111111111111111111111111'

 
A100:

I assert (and suggest checking) that when the timeframe is changed from M5 to M15 no M5 Deinit command is sent to the first indicator (and only to it - in this case M5) and it will not unload from the chart until the user deletes the EA

Glory is right and the unloading works correctly.

Note that in MT5, the indicator calculation core is a shared resource with a usage counter in its own manager. If different programs or windows use the indicator with the same parameters, one calculation copy with the usage counter actually works. This saves a lot of money when a trader uses the same indicators in charts and in an Expert Advisor.

The indicator manager is designed so that it physically deletes indicators asynchronously and with a delay. And in the meantime, a new working copy is created with new parameters, which is often initialized before the old copy is physically deleted.
 
Renat Fatkhullin:
The indicator manager is designed so that it physically removes indicators asynchronously and with a delay. And in the meantime a new working copy is created with new parameters, which is often initialised before the old copy is physically deleted.

Let's simplify the indicator

//Test_i.mq5 //Индикатор
void Prn( string f, int i = -1 ) { Print( f, "->", StringSubstr( EnumToString( Period()), 7 ), (i == -1 ? "" : ":" + i )); }
void OnInit()                    { Prn( __FUNCTION__ );         }
void OnDeinit( const int reason ) { Prn( __FUNCTION__, reason ); }
int OnCalculate( const int, const int, const int, const double& [] ) { return 0; }

Let's attach the Test.mq5 to the M5 chart and then change the chart period from M5->M15

Result:

2017.02.06 00:54:20.897 OnInit->M5
2017.02.06 00:54:25.553 OnInit->M15

Question: When will OnDeinit->M5 be called ?

My answer: Never!

Your answer above: asynchronously and with a delay

Files:
Test.mq5  1 kb