Proper IF statement

 

Hi; got a question.  Is the following a proper IF statement?

Example:

         if (CCIsig > CCI_Max && (CCIdirect=="U" || CCIdirect=="N")) cciFlag="buy";

or should it be:

         if ((CCIsig > CCI_Max && CCIdirect=="U") || (CCIsig > CCI_Max && CCIdirect=="N")) cciFlag="buy";

I much appreciate an answer; thank you.

 
  1. Both are logically the same. The first more efficient.
  2. Don't use strings (or int's) when you mean an enumeration.
    enumeration Status{eIdle, eBuy, eSell};
    
    Status cciFlag=eIdle;
    
    if(…) cciFlag=eBuy;

 

Hi William;

Thanks mate.  I learned something new today.  Thank you for sharing.  Much appreciated.


Lode

Reason: