Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
I am trying to capture in real time if any position is closed and then get its comment. not the last position in history.
whatever i try nothing seems to work, here is an example
can anyone give me a clue or it can not be done !
I suspect that this is a broker-dealer issue.
Broker-dealers can overwrite or altogether delete historic deal comments and magic numbers following stoploss execution.
As a universal workaround, you could set a series of GlobalVariables (GV's) following your stoploss executions; setting the GV name (a string) to your symbol, timeframe, and/or whatever, and the GV value (a double) to the magic number. In this way, you'd have a readymade list to read in the terminal. Then you can get their values in a loop somewhat like it's an array.
How about writing trade details to a file in this format:
TRADE_POSITION_TICKET:EA_MAGIC_NUMBERWhen the stop-loss is triggered, retrieve the TRADE_POSITION_TICKET. Once the ticket is found, extract the corresponding EA_MAGIC_NUMBER.
In that thread, the trade exit logic was coded into an EA. It really doesn't matter how you store/save the magic number, as long as the magic number is extracted from its definition the EA code. If you're auto-trading, then this applies.
If however you're trading manually, then just follow the advice in Post #2.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to capture in real time if any position is closed and then get its comment. not the last position in history.
whatever i try nothing seems to work, here is an example
can anyone give me a clue or it can not be done !