Run code on stop order activation - page 2

 
Alain Verleyen:

Sure there is a lot of ways. There is little chance "2" will change but still I don't like it because is not clear what that means...well of course we know it...anyway you see what I mean. Matter of taste.

For sure on my "real" code I don't use 2 times a function in a row...but on a forum it's good enough ;-)

I usually use a "switch":

switch( OrderType() )
{
   case OP_BUY:
   case OP_SELL:
      break;
      
   default:
      return; // invalid so return
}

// continue processing

This way I can also add code specific to the type if need be, within the "switch" statement.

switch( OrderType() )
{
   case OP_BUY:
      intPriceMode = MODE_ASK;
      intColour    = MediumSeaGreen;
      break;

   case OP_SELL:
      intPriceMode = MODE_BID;
      intColour    = MediumVioletRed;
      break;

   default:
      return( EMPTY );
}