drkenyi wrote >>
How can I get the ticket of the newly created order?
P.S.: I have a workaround, with couple of loops which collects all the tickets, before and after close, and figures the new ticket, but it is a little bit too much of network, and processor overhead.
Read a lot about it with no luck... or did I just missed something?
The 'workarounds', such as the one u mentioned, are probably the most reliable. But the answer also depends on the ticket's usage... Why do u need the newly created ticket number?
The 'workarounds', such as the one u mentioned, are probably the most reliable. But the answer also depends on the ticket's usage... Why do u need the newly created ticket number?
To close the order when its needed to be closed. Or to get the OpenTime, or openPrice,... or whatever I want
The same reason why the OrderSend() returns a ticket. New order, new ticket... CloseOrderBy() creates a new order, I need the ticket of it...
To close the order when its needed to be closed. Or to get the OpenTime, or openPrice,... or whatever I want
The same reason why the OrderSend() returns a ticket. New order, new ticket... CloseOrderBy() creates a new order, I need the ticket of it...
Well, most EA's don't 'remember' the tickets of their orders. They use the trade pool/ history pool as 'memory'. So most experts don't really 'know' ticket numbers, which is why I asked... But if your expert does 'remember' ticket numbers, then you should already have some sort of ticket memory framework, and so implementing a function to compare before and after close shouldn't be too complicated.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When I use this way of closing opposite orders in my EA, and the value of two orders does not match, then a new order will be placed by the broker with the difference of values of previous two orders.
Eg.
Order1 - Short, 2 lotsOrder2 - Long, 3 lots
OrderCloseBy(Order1, Order2); // https://docs.mql4.com/trading/OrderCloseBy
It will close the two previous orders, and create a new order:Order3 - Long, 1 lot
How can I get the ticket of the newly created order?
P.S.: I have a workaround, with couple of loops which collects all the tickets, before and after close, and figures the new ticket, but it is a little bit too much of network, and processor overhead.
Read a lot about it with no luck... or did I just missed something?