How it works in MetaTrader
An EA puts the number into the magic field of its trade request (in MQL5 an integer of type ulong; the standard CTrade class sets it with SetExpertMagicNumber). The number then stays on the order (ORDER_MAGIC), the deal (DEAL_MAGIC) and the position (POSITION_MAGIC). The MQL5 reference describes it as the ID of the Expert Advisor, meant for each EA to place its own unique number. Trades opened by hand have a magic of 0.
The number does two jobs. The EA itself picks «its» positions by symbol and magic, so it manages and closes only those. And when you analyse the account, magic splits the result between EAs and manual trading.
Example: the total hides a losing EA
Two EAs and manual trades share one account (model figures):
| Magic | Source | Trades | Result |
|---|---|---|---|
| 0 | manual | 40 | +$350 |
| 1001 | EA A | 120 | −$420 |
| 2002 | EA B | 60 | +$900 |
| — | whole account | 220 | +$830 |
The account is up, yet EA 1001 trades the most and loses money: without it the result would be +$1,250. A split by magic is the only way to see it.
Common mistakes
- The same magic for two EAs on one symbol: each treats the other's positions as its own.
- An EA selects positions without checking magic and closes manual trades.
- Changing the magic while positions are open: the EA no longer recognises them.
- A netting account: it holds one common position per symbol, so two EAs on the same symbol change one and the same position.
Magic numbers in Davinchu
The Davinchu Trade Monitor EA for MT5 and MT4 sends the magic of every trade, and the dashboard splits the account by it:
- «Account settings» → «Magic numbers» tab (for MetaTrader accounts): how many trades each number has, with 0 shown as «Manual trades».
- The trade card in the journal shows a «Magic» field.
- In the account's public statement, the «Magic number analysis» table shows trades, win rate and result for each number — if the owner enables it under «Permissions».
- AI review receives the results of each EA separately, while the «Tilt» alert counts manual trades only — EA trades are left out.
- The «EA settings» tab (MT5) has a «Magic Number» field under «Filters»: 0 makes the monitor send every trade on the account, any other number — only that EA's trades.
What an EA is and how to launch one — see «What is an Expert Advisor (EA)» and «How to install an EA in MT5». How to judge someone else's EA by its statistics — «How to check an EA or a signal before buying».
Frequently asked questions
What magic does a manual trade have?
Zero: the EA sets the number in its trade request, and a trade opened by hand does not get one. That is how manual trades are told apart from EA trades.
Can two EAs share one magic number?
If they trade different symbols and select positions by symbol and magic, there is no conflict. On the same symbol, a shared number makes the EAs manage each other's positions.
Where can I see the result for each magic?
In Davinchu, trade counts per number are on the «Magic numbers» tab of the account settings, and the result and win rate per number are in the «Magic number analysis» table of the account's public statement.