Errors, bugs, questions - page 2120

 
fxsaber:

Doesn't look like it's narrowly focused. Doesn't look like it's in the public domain yet.

It may well be an internal product of analysis of its own publicity, forum and something else
 
Комбинатор:
It may well be the internal product of analysis of its own publicity, forum and something else

The description somehow corresponds poorly with only internal usage.

 

?

void OnStart()
{
        int a = 0, b = 0; //Результат:
        Print(( ++a) + ( ++a)); //3
        Print((b+=1) + (b+=1)); //4
}

Result: 3 4

What's the difference?

 
A100:

?

Result: 3 4

What is the difference?

There is, of course, a difference. In the first case, first goes ++a, then +, then ++a.

The second is b+=1, then b+=1, then b+b.

 
Can you advise newbies? In the past, in MQL4, when writing a condition in an EA, we used to simply write Close[0] indicating the close price, for instance, a candle closed above the moving average and the order was opened. In MQL5 (for Forts) it doesn't work, different indicators can be compared via handles, but simple candlestick analysis will not work. Maybe, these candlesticks (high, low, open, close) have to be declared somewhere? For MT4, I just wrote Close[0] in the condition and the system understood that this is the close price of the current bar.
 
VadimR:
Can you advise newbies? In the past, in MQL4, when writing a condition in an EA, we used to simply write Close[0] indicating the close price, for instance, a candle closed above the moving average and the order was opened. In MQL5 (for Forts) it doesn't work, different indicators can be compared via handles, but simple candlestick analysis will not work. Maybe the candlestick data (high,low,open,close) have to be declared somewhere? But for MT4, I just wrote Close[0] in the condition and the system realized that this is the close price of the current bar.

Use function CopyXXXX

 
fxsaber:

There is, of course, a difference.

The second is b+=1, then b+=1, then b+b.

If you follow this logic then

void OnStart()
{
        int c = 0;    //Результат:
        Print( c     + (c+=1)); //1
}

First c+=1, then c+c and the result is 1+1= 2. And the result = 1

 
A100:

If you follow this logic then

First c+=1, then c+c and the result is 1+1= 2. And the result = 1

It only works incorrectly in the script, and it works fine in the EA.

I mean the previous example.

 
A100:

If you follow that logic then

First c+=1, then c+c and the result is 1+1= 2. And the result = 1

You're missing the logic.

Print((c+=0) + (c+=1)); //2
Print((c+=1) + c); //2
 
fxsaber:

You're missing the point.

If I don't get the logic, then why is the result https://www.mql5.com/ru/forum/1111/page2140#comment_6484866 the same in both cases in C99\C++?

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2018.02.05
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы
Reason: