https://www.mql5.com/en/docs/trading/ordergetticket
An example here allows to enumerates Tickets and their magic numbers.
Could you execute it before manual closure, and afterwards. And provide the output here.
I'm not sure whether magic number is affected by manual order closure.
Thanks.

Documentation on MQL5: Trade Functions / OrderGetTicket
- www.mql5.com
OrderGetTicket - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Thanks Siarhei, I managed to solve in a similar way.
double retornaValoreDiaFechado() { double Total_Fechadas= 0 ; datetime time_start; time_start = ( datetime ) ( 86400 *((( ulong ) TimeCurrent ())/ 86400 )); double position_id; if ( HistorySelect (time_start, TimeCurrent ())) { int hst = HistoryDealsTotal (); for ( int i = hst - 1 ; i >= 0 ; i--) { const ulong Ticket = HistoryDealGetTicket (i); if ( HistoryDealGetInteger (Ticket, DEAL_MAGIC ) == in_magic) Total_Fechadas += HistoryDealGetDouble (Ticket, DEAL_PROFIT ); else if ( HistoryDealGetInteger (Ticket, DEAL_MAGIC ) == 0 ) { position_id = HistoryDealGetInteger (Ticket, DEAL_POSITION_ID ); for ( int ii = hst - 1 ; ii >= 0 ; ii--) { ulong Ticket2 = HistoryDealGetTicket (ii); if ( HistoryDealGetInteger (Ticket2, DEAL_MAGIC ) == in_magic && HistoryDealGetInteger (Ticket2, DEAL_POSITION_ID ) == position_id) Total_Fechadas += HistoryDealGetDouble (Ticket, DEAL_PROFIT ); } } } } return Total_Fechadas; }

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
Would you have any example of how I can capture the data of manually closed orders that started from an EA by magic number?
The problem in this case is to know which robot originated the order.
I need to know the value generated by each entry made by the EA even if it was completed manually.
I have more than 1 EA with different magic numbers running on the same symbol.