Download MetaTrader 5
To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
chua le
234
chua le 2016.09.23 03:37 

Dear All,

 

Can I use the expression as below? Meaning can I use || the OR operaror in the expression?

while ((PA<=20 && PA>0) || (PA>=-20 && PA<0))

.........

 .......

 

Thanks 

Fernando Carreiro
1468
Fernando Carreiro 2016.09.23 04:24  

Yes, that is perfectly valid, but I would suggest (as a personal opinion) that you add a few extra parenthesis, in order to make the Precedence Rules more explicit and apparent which will prevent accidental logic bugs in the future.

while( ( ( PA >    0 ) && ( PA <= 20 ) ) ||
       ( ( PA >= -20 ) && ( PA <   0 ) )    )
{
   // ...
}

The above code is just my personal style. There is nothing wrong with your code and it is completely valid!

chua le
234
chua le 2016.09.23 04:34  
FMIC:

Yes, that is perfectly valid, but I would suggest (as a personal opinion) that you add a few extra parenthesis, in order to make the Precedence Rules more explicit and apparent which will prevent accidental logic bugs in the future.

The above code is just my personal style. There is nothing wrong with your code and it is completely valid!

Thanks Bro.
/
To add comments, please log in or register