Download MetaTrader 5

order Select

To add comments, please log in or register
amando
423
amando  

hello

 

in mql4 i used following code

 

   for (i=0;i<OrdersTotal();i++){
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if( OrderMagicNumber()==Magic){
         if(OrderType()==OP_BUYSTOP || OrderType()==OP_BUY) Bought++;
         if(OrderType()==OP_SELLSTOP || OrderType()==OP_SELL) Sold++;
      }
   }
  
 

    
   if( Bought==0  ){ //no buy order
  
      Ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots, Long ,3, SLLong, 0,Text,Magic,TimeCurrent() + 119*60*60,Blue);
     
        }

this works very well

but in mql5

   for (int i=0;i<OrdersTotal();i++){
      //OrderSelect(0,0);
      if(ORDER_COMMENT == Text && ORDER_MAGIC == MN){
         if(ORDER_TYPE == ORDER_TYPE_BUY  || ORDER_TYPE == ORDER_TYPE_BUY_STOP)  Bought++;
         if(ORDER_TYPE == ORDER_TYPE_SELL || ORDER_TYPE == ORDER_TYPE_BUY_STOP)  Sold++;
      }
   }

 

dont work this code

 

how i have to write it?

 

 

regards

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
Rashid Umarov
Admin
11993
Rashid Umarov  
See sample for function OrderGetTicket


And try to insert code properly.


Kray
31
Kray  
Thanks
To add comments, please log in or register