Opened the terminal after a few days of non-use. Got this picture. Then used the script to upload the history. No change. Waited a couple of hours. Everything's fine now.
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
Yes, we can. It's all about implementation of x = x++;
Before postincrement, the x value is saved into a temporary variable. Then an increment is performed. Then an assignment is made from the temporary variable.
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
You need to initialize variables before you perform mat operations on them. If you just assign it to an uninitialized variable, everything will be fine.
However, it's always a good idea to initialize variables to avoid trouble.
What was the action before that?
Does the update help?
Opened the terminal after a few days of non-use. Got this picture. Then used the script to upload the history. No change. Waited a couple of hours. Everything's fine now.
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
PS. Should read ... x==1 and y==0 ...
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
Check here https://www.mql5.com/ru/docs/basis/operations/mathoperation
The compiler won't display any errors or warnings?
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
We checked, the result is x=1, y=0
the first increment x=x++ decomposes into
t=x; // x=0
x++; // x=1
x=t; // x=0
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
Yes, we can. It's all about implementation of x = x++;
Before postincrement, the x value is saved into a temporary variable. Then an increment is performed. Then an assignment is made from the temporary variable.
Look here https://www.mql5.com/ru/docs/basis/operations/mathoperation
The compiler doesn't display any errors or warnings?
The MT5 compiler swallows it silently! It does not compile in MT4.
Out of curiosity, I tried a similar construct in C++ (from Visual Studio 2005) and the result for x and y is the same.
Can you explain why according to the results of the run x==0 and y==1 ? Build 342
You need to initialize variables before you perform mat operations on them. If you just assign it to an uninitialized variable, everything will be fine.
However, it's always a good idea to initialize variables to avoid trouble.
The MT5 compiler swallows silently! In MT4 the compilation fails.
Out of curiosity I tried a similar construction in C++ (from Visual Studio 2005) - the result for x and y is the same.
This place is not defined in the c++ standard and it is explicitly stated that it depends on the implementation. There are 2 main implementations:
1. Perform a postincrement immediately after using a variable in an expression. (as we have done).
2. Postincrement after the whole expression is calculated.
I mean, where can I find out which brokers run MT5 on real time?