How to obtain (Ticket Number) of closed order?
-
I'm trying to get the (Ticket Number) of the last order that closed, but it's not giving it to me, instead it's giving me the (Deal), does anyone know why this is happening?
I want to get the same number as the Ticket Number of the order that was opened after it was closed.
In the project below I demonstrate how my unsuccessful attempts were. -
The "ticket" refers to the unique identifier assigned to each trading operation in MetaTrader 5 (MT5). It is generated whenever a position is opened, modified, or closed. This unique identifier allows precise tracking of each operation and is used to reference specific operations in functions and queries.
For example, when opening a new position, the returned "ticket" can be subsequently used to modify or close that specific position.
-

-
@diazoviedo
Got it, but test it yourself.
Open an order, and get the ticket, it will for example get the (ticket number) 00001111.
Close this same order, and get the ticket, it will, for example, get the (deal) 00002222 or 00006789, it will not bring the (ticket number) 00001111.I don't understand why he simply exchanges obtaining the (ticket number) for the (deal).