Beginner's questions in MQL5. Professionals don't pass by. - page 8

 

Help to get a ticket for a single pending order. It doesn't work like this:

      Print("количество ордеров ",OrdersTotal());
      if(OrderGetTicket(1))
     {
      Print("тикет ",OrderGetInteger(ORDER_POSITION_ID)); 
     }
 
ascerdfg:

Help to get a ticket for a single pending order. It doesn't work like this:

Numbering of the order list starts with zero, not one.
 
Vasiliy Pushkaryov:
The numbering of the order list starts with zero, not one.

I have tried zero as well.

 
ascerdfg:

Help to get a ticket for a single pending order. It doesn't work like this:

Why don't you do a check to see exactly what you've retrieved?

Run the example from the help OrderGetTicket is a script:

void OnStart() 
  { 
//--- переменные для получения значений из свойств ордера 
   ulong    ticket; 
   double   open_price; 
   double   initial_volume; 
   datetime time_setup; 
   string   symbol; 
   string   type; 
   long     order_magic; 
   long     positionID; 
//--- количество текущих отложенных ордеров 
   uint     total=OrdersTotal(); 
//--- пройдем в цикле по всем ордерам 
   for(uint i=0;i<total;i++) 
     { 
      //--- получим тикет ордера по его позиции в списке 
      if((ticket=OrderGetTicket(i))>0) 
        { 
         //--- получим свойства ордера 
         open_price    =OrderGetDouble(ORDER_PRICE_OPEN); 
         time_setup    =(datetime)OrderGetInteger(ORDER_TIME_SETUP); 
         symbol        =OrderGetString(ORDER_SYMBOL); 
         order_magic   =OrderGetInteger(ORDER_MAGIC); 
         positionID    =OrderGetInteger(ORDER_POSITION_ID); 
         initial_volume=OrderGetDouble(ORDER_VOLUME_INITIAL); 
         type          =EnumToString(ENUM_ORDER_TYPE(OrderGetInteger(ORDER_TYPE))); 
         //--- подготовим и выведем информацию об ордере 
         printf("#ticket %d %s %G %s at %G was set up at %s", 
                ticket,                 // тикет ордера 
                type,                   // тип 
                initial_volume,         // выставленный объем 
                symbol,                 // символ, по которому выставили 
                open_price,             // указанная цена открытия 
                TimeToString(time_setup)// время установки ордера 
                ); 
        } 
     } 
//--- 
  }
 
Print("тикет ",OrderGetTicket(0));
That's how it works!
Reason: