Debug - OrderGetTicket always returning zero

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](https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_property_double)); 

         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 

                ); 

        } 

     }

Hello,

Please EDIT your post and use the SRC button when you post code.

Thank you.

Hi,

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

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

You should update your trading vocabulary

Yes, I do (^̮^) …

thanks htwyford1p & vpeabody1

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