You have to loop through the list of all open positions looking for other criterias (_Symbol, open time open price,..) of the position then you can get the ticket number.
void OnTrade() { long order_ticket; int order_magic; ENUM_ORDER_TYPE order_type; int curr_orders=OrdersTotal(); for(int i=curr_orders-1; i>=0; i--) { order_ticket=(long)OrderGetTicket(i); if(OrderGetString(ORDER_SYMBOL)!=_Symbol) continue; order_magic=(int)OrderGetInteger(ORDER_MAGIC); order_type=ENUM_ORDER_TYPE(OrderGetInteger(ORDER_TYPE)); if(order_type==ORDER_TYPE_BUY_STOP) { //.... } if(order_type==ORDER_TYPE_SELL_STOP) { //... } //... } //... return; }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys
To control (OrderSelect) the orders, we must have their ticket numbers.
To catch that ticket number, we can get it when order is sent
int ticket = OrderSend(............)
But what if i want get the ticket numbers of all existing orders by EA (i.e. store the ticket numbers one by one into variables?
I've read the docs and books and have no clues. Please help.