Download MetaTrader 5

Closing Order Partially in MQL4 and Getting the Ticket Number For the Rest of The Order.

To add comments, please log in or register
Marcos Silva
358
Marcos Silva  

Hi,

Im a little bit confused with the ticket number for the order remaining, i have been doing tests and the order closed partially is the one with the ticket number already assigned with the beginning lots so whats the number for the lots left?

Ex:

I open an order with 1 lot and get ticket number 11.

I close order 11 using only 0.6 lots.

What is the ticket number for the remaining 0.4 lots?

Is that a way for me to know that number when i close order 11?

Ian Flanagan
549
Ian Flanagan  

Good question. My broker shows it in the common of the order, I guess maybe you can't rely on that though.

One way is give each order a unique magic number or comment.

Another way to try is search all open orders for the correct ticket number, store it's position, then get the ticket number of the same position after partially closing. Just don't open or close other orders in the mean time. I don't know if partially closing changes to order position, maybe if it sticks the order at the end, it will make it easier

Marcos Silva
358
Marcos Silva  
whroeder1
15922
whroeder1  
investguy:
so whats the number for the lots left?
What is the ticket number for the remaining 0.4 lots?
Is that a way for me to know that number when i close order 11?
  1. New = Original - Close. DUH
  2. Assigned by the broker just like the original. DUH
  3. OrderSelect loop (counting down) and find the new one.
GreenMoney
379
GreenMoney  
investguy:

Hi,

Im a little bit confused with the ticket number for the order remaining, i have been doing tests and the order closed partially is the one with the ticket number already assigned with the beginning lots so whats the number for the lots left?

Ex:

I open an order with 1 lot and get ticket number 11.

I close order 11 using only 0.6 lots.

What is the ticket number for the remaining 0.4 lots?

Is that a way for me to know that number when i close order 11?

This code may help you some. It is an example function which partially closes an open order and returns the ticket number of the newly created order.
Marcos Silva
358
Marcos Silva  
Great help indeed thank you guys !
To add comments, please log in or register