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.
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- How to take partial profits -- OP_SELLLIMIT?
- Errors, bugs, questions
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).
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.
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).
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).
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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