Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
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
Hi, Stephane,
This works on me, even though there are many positions.
ohh.. yes, you're right .
I mean "positions" of pending orders
not code syntax for position PositionsTotal() .. 。◕‿◕。
Thanksohh.. 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 (^̮^)
Yes, I do (^̮^)
thanks Alain & Yohana
everything is ok, i'm working with Positions, it's better

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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
);
}
}