Multiple OR statements
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:
Precedence goes from left to right . . . . https://docs.mql4.com/basis/operations/rules
Is there precedence?
Thanks for any insight!
if ( rsiG > 70 ||AO.1H > 0 || rsiD > 50 || rsiD < 30 && SDO.030M > SDO.130M )
- 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) )
orif ( (rsiG > 70 ||AO.1H > 0 || rsiD > 50) || (rsiD < 30 && SDO.030M > SDO.130M) )
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.
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?
Thanks for any insight!