How can we know magic number of an open trade in MT4?

 

Dear everybody,


I have an EA that I run simultaneously on several charts at once, on just one symbol pair, but with different time frames. Of course I did this as a strategy to reduce the risk as small as possible. But the problem is, if a trade is opened by the EA, on more than one chart simultaneously, and I have to evaluate which trade comes from a particular chart, I can't do it because the magic number cannot be known in MT4.

I can find out the magic number of a trade easily in MT5. Is there a method or indicator or EA that can help identify magic numbers in MT4? Thank you for the info

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

The magic numbers are openly available in MT4, both via the MQL4 programming, as well as on your trading history.

In your code, once you have selected the order via OrderSelect, you can obtain its magic number via the function OrderMagicNumber.

OrderSelect - Trade Functions - MQL4 Reference
OrderSelect - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderSelect - Trade Functions - MQL4 Reference
 
I'm not the developer of the EA, and I can't write a code to build an EA. I'm just a user. When the trades still open, how can I know the magic number of that trade in MT4?
 
Wan Suryolaksono #: Thanks, now I'm waiting for the idea to solve this problem....
What do you mean by "I'm waiting for the idea to solve this problem"?
 
Wan Suryolaksono #: I'm not the developer of the EA, and I can't write a code to build an EA. I'm just a user. When the trades still open, how can I know the magic number of that trade in MT4?
As I stated, the Magic number is visible in the Trade History. Just hover over the ticket number of the order with your mouse and a tooltip will appear.
 
Fernando Carreiro #:
As I stated, the Magic number is visible in the Trade History. Just hover over the ticket number of the order with your mouse and a tooltip will appear.

Thank you very very much for your help. I don't know about tooltip when hovering the ticket number can give this important info. Thanks again

 
Wan Suryolaksono :

Vážení všichni,


Mám EA, které spouštím současně na několika grafech najednou, pouze na jednom páru symbolů, ale s různými časovými rámci. Samozřejmě jsem to dělal jako strategii, abych snížil riziko co nejmenší. Problém je ale v tom, že pokud je obchod otevřen EA, na více než jednom grafu současně, a já musím vyhodnotit, který obchod pochází z konkrétního grafu, nemohu to udělat, protože magické číslo nelze v MT4 znát.

V MT5 mohu snadno zjistit magické číslo obchodu. Existuje metoda nebo indikátor nebo EA, které mohou pomoci identifikovat magická čísla v MT4? Děkuji za info

The EA can be recognized by hovering over the comments and the magic number will appear.

 
Wan Suryolaksono: I can't do it because the magic number cannot be known in MT4.
  1. Perhaps you should read the manual, or press F1 in the editor. Of course, they are known.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  2. Convert the timeframe (ENUM_TIMEFRAMES) to a compact form (my TF) and add it to a base Magic number.
              Why are MT5 ENUM_TIMEFRAMES strange? - General - MQL5 programming forum - Page 2 #11 (2020)