Multiple OR statements

 

Can anyone tell me if there are limits on OR statements? e.g. I run several possibilities in my close statement but it appears that all of the conditions are not read. Is there precedence?

/CLOSE SELL
   
      if ( rsiG > 70 ||AO.1H > 0 || rsiD > 50 || rsiD <  30 && SDO.030M > SDO.130M  )  
       {

Thanks for any insight!

 

Be sure you set the brackets right. In this case i suggest to set extra brackets so that the if statement will be nice to read

 
LINE123:

Is there precedence?

Thanks for any insight!

Precedence goes from left to right . . . . https://docs.mql4.com/basis/operations/rules
 
if ( rsiG > 70 ||AO.1H > 0 || rsiD > 50 || rsiD <  30 && SDO.030M > SDO.130M  )  
  1. Yes, there is a precedence, don't use it. Don't mix ANDs and ORs, use parenthesis. Did you mean
    if ( (rsiG > 70 ||AO.1H > 0 || rsiD > 50 || rsiD <  30) && (SDO.030M > SDO.130M)  )  
    or
    if ( (rsiG > 70 ||AO.1H > 0 || rsiD > 50) || (rsiD <  30 && SDO.030M > SDO.130M)  )  

  2. Better is to document your conditions and bad logic combinations usually become obvious.
    bool overBrought     = rsiG > 70 ||AO.1H > 0 || rsiD > 50,
         lowerTFturnDown = rsiD < 30,
         sdoIsUp         = SDO.030M > SDO.130M;
    if ( (overBrought || lowerTFturnDown) && sdoIsUp  )  
    Obviously I don't know what your variables actually represent.
 
Thank you all for contributing. MQL code teaches me humility :( Mr. Roeder, thank you for clarifying this.
if ( rsiG > 70 ||AO.1H > 0 || rsiD > 50 || rsiD <  30 && SDO.030M > SDO.130M  ) 

Close sell if

rsiG = rsi on lower tf > 70

or

AO.1H = Awesome Osc on lower tf > 0

or

rsiD = rsi on current tf > 50

or

rsiD = rsi on current tf < 30 now shut it down if the SDO is crossing. This is to pick up fast moves and lock in profit.