Errors, bugs, questions - page 161

 
alexvd:

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 tell me where I can find out who has the MT5 running on a real account?
 
void OnStart()
  {
//---
   int x,y = 0;
   Print("x++:");
   x = x++;
   Print("x=",x," y=",y);
   y = x++;
   Print("x=",x," y=",y);
  }

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 ...

 
Ashes:

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?

Документация по MQL5: Основы языка / Операции и выражения / Арифметические операции
Документация по MQL5: Основы языка / Операции и выражения / Арифметические операции
  • www.mql5.com
Основы языка / Операции и выражения / Арифметические операции - Документация по MQL5
 
Ashes:

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

 
Ashes:

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.

 
Lizar:

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.

 
Ashes:

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.

void OnStart()
  {
//---
   int x=0,y = 0;
   Print("x++:");
   x++;
   Print("x=",x," y=",y);
   y=x;
   Print("x=",x," y=",y);
  }
 
Ashes:

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?

Reason: