MQL5, why ordergetticketalways return 0 ?

 

hi guys,

here is classical code, but OrderGetTicket() always return 0 even if i have a lot of orders

OrdersTotal()is ok

why ? 



 uint     total=OrdersTotal(); 

  //--- go through orders in a loop 

   for(uint i=0;i<total;i++) 

     { 

      //--- return order ticket by its position in the list 

      if((ticket=OrderGetTicket(i))>0) 

        { 

         //--- return order properties 

         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))); 

         //--- prepare and show information about the order 

      

         printf("#ticket %d %s %G %s at %G was set up at %s", 

                ticket,                 // order ticket 

                type,                   // type 

                initial_volume,         // placed volume 

                symbol,                 // symbol 

                open_price,             // specified open price 

                TimeToString(time_setup)// time of order placing 

                ); 

        } 

     } 

 
Stephane Reynaud:

hi guys,

here is classical code, but OrderGetTicket() always return 0 even if i have a lot of orders

OrdersTotal()is ok

why ? 

 


Hi, Stephane,

This works on me, even though there are many positions.

     //+-------------------------------+
     //| Get data from pending orders  |
     //+-------------------------------+
     ulong ticket;
     ulong total=OrdersTotal();
     for (ulong i=0; i<total; i++) 
     {
       if((ticket=OrderGetTicket(i))>0)
       {  
           //--do something
           Print("* Ticket: ",ticket);

       }//--end if
     }//--end for
 
Yohana Parmi:

Hi, Stephane,

This works on me, even though there are many positions.

OrdersTotal() is related to pending orders, not to positions.
 
Alain Verleyen:
OrdersTotal() is related to pending orders, not to positions.

ohh.. yes, you're right .

I mean "positions" of pending orders 

not code syntax for position PositionsTotal() ..  。◕‿◕。

Thanks
 
Yohana Parmi:

ohh.. yes, you're right .

I mean "positions" of pending orders 

not code syntax for position PositionsTotal() ..  。◕‿◕。

Thanks
You should update your trading vocabulary
 
Alain Verleyen:
You should update your trading vocabulary

Yes, I do (^̮^)

 
Yohana Parmi:

Yes, I do (^̮^)


thanks Alain & Yohana

everything is ok, i'm working with Positions, it's better