Errors, bugs, questions - page 3130

 
Alexey Viktorov #:

I don't understand this code at all.

What does the highlighted & in this code mean? And in which loop should if(h_plus) be executed? Didn't you miss any curved brackets?

MQL bool is true if greater than 0, in other languages a boolean value is true only if == 1

 
Alexey Viktorov #:

I don't understand this code at all.

What does the highlighted & in this code mean? And in which loop should if(h_plus) be executed? Aren't you missing any curved brackets?

 bool h_plus=true; //false?
   for(int increment=1; increment<=n; increment++)
      h_plus&=high[i]>high[i+increment];
   if(h_plus) {...}
   ...


 
x572intraday #:

In fact, I came across this feature by accident. That's not what I wanted...

or

The trouble is that n can be quite large, so I wanted to wrap up this long chain of conditions into a compact for. I tried it this way:

but it turned out to be a bit of a mess. Well at least because h_plus with this algorithm will have to take the whole sum of checked conditions, including the condition with redundant index array check, which didn't happen in first unwrapped if, without for. And other varnings spoil the picture.

Is this even worth considering? Is it possible to override it?

Something like this:

for(int i=start; i<rates_total-3 && !IsStopped(); i++)
{
   bool h_plus=true; //false?
   for(int increment=1; increment<=n; increment++)
     {
      h_plus&=high[i]>high[i+increment];
      if(!h_plus)break;
     }
   if(h_plus) {...}
   ...
}
 
Lilita Bogachkova #:


Bitwise AND operation of binary representations of y and x y &= x;

https://www.mql5.com/ru/docs/basis/operations/assign

Документация по MQL5: Основы языка / Операции и выражения / Операции присваивания
Документация по MQL5: Основы языка / Операции и выражения / Операции присваивания
  • www.mql5.com
Операции присваивания - Операции и выражения - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Lilita Bogachkova #:


Which line of your snapshot has &=

 
JRandomTrader #:

Bitwise AND operation of binary representations of y and x y &= x;

https://www.mql5.com/ru/docs/basis/operations/assign

I see. It's not for the self-taught... I was too lazy to look there...
 
Alexey Viktorov #:

I don't understand this code at all.

What does the highlighted & in this code mean?

I can only answer for &= immediately:

MQL5 Reference Guide / Language basics / Operations and expressions / Assignment operations:

Bitwise operation AND of binary representations of y and x y &= x;

similar to the cumulative variable y:

Increasing the value of the y variable by x y += x;


But this is my first experience of using &=, so I could be wrong.

And in which loop should the if(h_plus) be executed? Did you miss the curved brackets?

No. First (by design) all logical conditions are summed up in the accumulative h_plus inside for, and the resulting bool sum is substituted in the if, which has nothing to do with the internal for.
 
Alexey Viktorov #:

Which line of your image has &=

https://stackoverflow.com/questions/33304407/c-meaning-and

C++ meaning |= and &=
C++ meaning |= and &=
  • 2015.10.23
  • Sven van den Boogaart
  • stackoverflow.com
I have a part of code that contains the following functions: I know what a switch case is but I don't understand what these parts do. is an int. The 's also refer to an int value. Could someone explain what these parts do? An example with input values and results would be nice.
 
Lilita Bogachkova #:

You think too much of me... I never learned this enemy language... so it happened... and now it's too late.

 
JRandomTrader #:

Something like that:

I've already tried both break and even return in the heat of the moment, but it only made things worse. I'll try to simplify the code some more and rethink with break...