Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 has classes?
manu
78
manu 2014.02.16 10:03 

Hello,

Sorry for my bad English.

I compile my old EA in the build 604 format and I receive a warning "Check operator precedence for possible error; use parentheses to clarify precedence" on the OrderSelect line.

I try to integrate parentheses, but the warning stay.

If someone had a idea to delete this message, thanks

Emmanuel


Total_Orders = OrdersTotal();
   Compteur_cet_EA = 0;
   
   for(Position_Index = Total_Orders - 1; Position_Index >= 0 ; Position_Index --)
      {        
      if (
         OrderSelect(Position_Index, SELECT_BY_POS, MODE_TRADES) &&
         (OrderType() == OP_BUY && OrderMagicNumber()==Colombanaise_MACD_Magic_Number) ||
         (OrderType() == OP_SELL && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)||
         (OrderType() == OP_BUYLIMIT && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)||
         (OrderType() == OP_SELLLIMIT  && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)
         )   
         
         {
         Compteur_cet_EA = Compteur_cet_EA + 1;
         }     
      }
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.16 10:06  
arsouille:

Hello,

Sorry for my bad English.

I compile my old EA in the build 604 format and I receive a warning "Check operator precedence for possible error; use parentheses to clarify precedence" on the OrderSelect line.

I try to integrate parentheses, but the warning stay.

If someone had a idea to delete this message, thanks

Which first && or || ?

OrderSelect(Position_Index, SELECT_BY_POS, MODE_TRADES)    &&       
         (OrderType() == OP_BUY && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)    ||      
Alain Verleyen
Moderator
28701
Alain Verleyen 2014.02.16 10:27  
arsouille:

Hello,

...
Voilà.
   Total_Orders = OrdersTotal();
   Compteur_cet_EA = 0;
   
   for(Position_Index = Total_Orders - 1; Position_Index >= 0 ; Position_Index --)
      {        
      if (
         OrderSelect(Position_Index, SELECT_BY_POS, MODE_TRADES) &&
         ((OrderType() == OP_BUY && OrderMagicNumber()==Colombanaise_MACD_Magic_Number) ||
         (OrderType() == OP_SELL && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)||
         (OrderType() == OP_BUYLIMIT && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)||
         (OrderType() == OP_SELLLIMIT  && OrderMagicNumber()==Colombanaise_MACD_Magic_Number))
         )   
         
         {
         Compteur_cet_EA = Compteur_cet_EA + 1;
         }     
      }
aaaacom
117
aaaacom 2014.02.16 10:28  
      int Position_Index, Colombanaise_MACD_Magic_Number;
      bool X = (
         OrderSelect(Position_Index, SELECT_BY_POS, MODE_TRADES) &&
         ((OrderType() == OP_BUY && OrderMagicNumber()==Colombanaise_MACD_Magic_Number) ||
         (OrderType() == OP_SELL && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)||
         (OrderType() == OP_BUYLIMIT && OrderMagicNumber()==Colombanaise_MACD_Magic_Number)||
         (OrderType() == OP_SELLLIMIT  && OrderMagicNumber()==Colombanaise_MACD_Magic_Number))
         );   
   

a && b || c || d || e -> new code: a && (b || c || d || e)

manu
78
manu 2014.02.16 10:39  

Thanks a lot, you have corrected my warning and above, I understood.

Regards

/
To add comments, please log in or register