English

## check operator precedence for possible error; use parentheses to clarify precedenc

 86 fly7680 2016.07.24 11:27   I enter the condition in the candle 2 if Red or Green with I cover more than 0.2 pipsI have this error: check operator precedence for possible error; use parentheses to clarify precedenchelp me solve please?`&&(Open[2+i] < Close[2+i]  && MathAbs(Close[2+i]-Open[2+i]) > 0.2  * myPoint || Open[2+i] > Close[2+i]  && MathAbs(Open [2+i]-Close[2+i]) > 0.2  * myPoint)`
 164 drazen64 2016.07.24 13:02 #   This is not an error, but a warning that you are mixing "&&" and "||" in the same boolean expression.  Although it may be what you want, there is a huge chance that you may have a bug in there. Your expression, as is, will be evaluated in this order:```bool b1 = Open[2+i] < Close[2+i]  && MathAbs(Close[2+i]-Open[2+i]) > 0.2  * myPoint; bool b2 = b1  || Open[2+i] > Close[2+i]; bool b3 = b2  && MathAbs(Open [2+i]-Close[2+i]) > 0.2  * myPoint;```  You probably want it to be evaluated: "left side" || "right side".  If so, use parenthesis. If not, again, use parenthesis, to explain to the compiler what exactly you want. Also, you should consider chopping up this expression into meaningful pieces to make the code more readable.```bool bullishCandle = Open[2+i] < Close[2+i]; double candleBodySize  = MathAbs(Close[2+i]-Open[2+i]); bool candleHighEnough  = candleBodySize > (0.2 * myPoint); // which leads to expression: bool result = (bullishCandle && candleHighEnough) || (!bullishCandle && candleHighEnough); // which is equivalent to: bool result = candleHighEnough && (bullishCandle || !bullishCandle); // since "(bullishCandle || !bullishCandle)" is always true, above is equivalent to: bool result = candleHighEnough; ```