Which order is selected after a partial close?

 
After closing part of an order at a take profit level which order in the order book is selected? I know the ticket of the trade changes, and therefore I assume it's position but not sure if the trade remains selected regardless of this.
 
whitebloodcell:
After closing part of an order at a take profit level which order in the order book is selected? I know the ticket of the trade changes, and therefore I assume it's position but not sure if the trade remains selected regardless of this.
When u select an order a buffer is filled with all order details (the ones that can be retrieved with the trading functions - OrderTicket(), OrderTakeProfit(), etc.). This buffer will contain these details until the next time OrderSelect() is called. Hence, regardless of whether an order was closed at TP or even manually, the order will still be 'selected' and the data contained in the buffer will be the data that was 'captured' at the time of order selection (until the next time OrderSelect() is called).
 
gordon:
When u select an order a buffer is filled with all order details (the ones that can be retrieved with the trading functions - OrderTicket(), OrderTakeProfit(), etc.). This buffer will contain these details until the next time OrderSelect() is called. Hence, regardless of whether an order was closed at TP or even manually, the order will still be 'selected' and the data contained in the buffer will be the data that was 'captured' at the time of order selection (until the next time OrderSelect() is called).


Thanks for the quick reply!

So if I am understanding this right, the value contained in OrderTicket() will still be the previous ticket, not the newly assigned one? If that is the case, are newly created orders assigned the position '0' in the order book?

 
whitebloodcell:

So if I am understanding this right, the value contained in OrderTicket() will still be the previous ticket, not the newly assigned one?

That's correct. This buffer is static; it only updates when OrderSelect() is called.

If that is the case, are newly created orders assigned the position '0' in the order book?
Generally yes, but there might be situations when this won't necessarily be the case... It's considered good practice to loop on all orders and find the relevant one rather than assuming that position '0' holds a specific order (this is also a matter of opinion.... this is IMHO).
Reason: