Download MetaTrader 5

I want check to a symbol ()

To add comments, please log in or register
Tiago Cetto Pietralonga
509
Tiago Cetto Pietralonga 2016.07.11 02:17 

 I want check to a symbol ()

 Thank you

 

if(OrdersTotal() > 0){ // verifica se existe ordens abertas
     
      for(int i=OrdersTotal();i>=0;i--){ // cria um loop decrescente com valor inicial igual ao total de ordens abertas
        
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ // seleciona a ordem dentro do loop
             
             switch(OrderType()){ // verifica o tipo da ordem 
                  case 0:
                      // 0 - buy
                        
                  case 1:                     
                        // 1 - sell
                        
                  case 2: 
                        // 2 - buy limit 
                        
                  case 3:
                        // 3 - sell limit
                        
                  case 4:
                        // 4 - buy stop
                        
                        
                  case 5:          
                        // 5 - sell stop     
                        
                                            
            } 
       }   
  }
}
Rodrigo Malacarne
Moderator
9940
Rodrigo Malacarne 2016.07.11 05:19  
Tiago Cetto Pietralonga:

 I want check to a symbol ()

 Thank you

Hi Tiago Cetto Pietralonga,

Please try to use the SRC button when pasting parts of code there in the Forum.

This time I'll do that for you. 

Regards,
Malacarne 

Marco vd Heijden
Moderator
4728
Marco vd Heijden 2016.07.11 05:32  
Tiago Cetto Pietralonga:

 I want check to a symbol ()

 Thank you

 

//+------------------------------------------------------------------+
if(OrdersTotal()>0)
  { // verifica se existe ordens abertas

   for(int i=OrdersTotal();i>=0;i--)
     { // cria um loop decrescente com valor inicial igual ao total de ordens abertas

      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        { // seleciona a ordem dentro do loop

         switch(OrderType())
           { // verifica o tipo da ordem 
            case OP_BUY:
               // 0 - buy

               break;
            case OP_SELL:
               // 1 - sell

               break;
            case OP_BUYLIMIT:
               // 2 - buy limit 

               break;
            case OP_SELLLIMIT:
               // 3 - sell limit

               break;
            case OP_BUYSTOP:
               // 4 - buy stop

               break;
            case OP_SELLSTOP:
               // 5 - sell stop     

               break;
           }
        }
     }
  }
//+------------------------------------------------------------------+
Anton Nel
37603
Anton Nel 2016.07.11 11:29  

This will check out for Symbol()

//+------------------------------------------------------------------+
   int ordersTotal = OrdersTotal();

   //--- search in all open positions
   for (int i = ordersTotal - 1; i >= 0; i--)
   {
      //--- if an error occurs at selecting of this position then go to the next one...
      if (!OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) continue;

      //--- if the position was opened not for the current symbol, skip it...
      if (OrderSymbol() != Symbol()) continue;

      switch(OrderType())
      { 
         case OP_BUY:
            // 0 - buy
            break;

         case OP_SELL:
            // 1 - sell
            break;

         case OP_BUYLIMIT:
            // 2 - buy limit 
            break;

         case OP_SELLLIMIT:
            // 3 - sell limit
            break;

         case OP_BUYSTOP:
            // 4 - buy stop
            break;

         case OP_SELLSTOP:
            // 5 - sell stop     
            break;
        }
     }
  }
//+------------------------------------------------------------------+
Tiago Cetto Pietralonga
509
Tiago Cetto Pietralonga 2016.07.11 16:59  
Anton Nel:

This will check out for Symbol()

Thank you, it's working

To add comments, please log in or register