Guide · MetaTrader
The magic number in MetaTrader: what it is and why it's not enough.
Every robot signs its trades with a number. It keeps them apart within one account, but it falls short as soon as your EAs trade on several.
What it is
The magic number is an integer the EA puts on every order it opens. MetaTrader stores it along with the trade. Thanks to it, a robot knows which positions are its own and leaves another's alone, even when they trade the same symbol.
It's also what almost every tracking tool uses to separate each EA's result within an account.
Where it breaks down
Same robot, different number
When you put the EA on a second account, a challenge or another broker, it's common to change its magic so you don't mix it up. For a tool that only looks at that number, they're now two different robots, each with half a history.
Different robot, same number
The reverse happens too: two strategies can end up with the same magic if you don't change it when exporting them. Their trades get mixed and the figures stop making sense.
The symbol, written each broker's way
EURUSD, EURUSD.r, EURUSDc: every broker adds its own suffix. To compare the same EA across accounts, you have to recognize that it's the same pair.
Best practices
- Use a different magic per strategy and keep a list of them.
- Give each EA a comment that identifies it; many add it to their orders.
- Don't change the magic of a robot that already has a history, unless you have to.
Where to find it
It appears in the EA's inputs, almost always under a name like MagicNumber, Magic or ID. You choose it when you attach the robot to the chart.
Orders opened by hand carry the value 0.
A numbering scheme that works
Pick a rule so you never repeat one. For example, five digits where the first ones indicate the symbol, with the last ones reserved for the strategy.
- 11001: first EURUSD strategy.
- 11002: the second one on the same pair.
- 21001: the first one on gold.
Keep the list in a spreadsheet along with the name, the timeframe, the date it was added.
The order comment
Alongside the magic, each trade accepts a short text. Many EAs write their name there.
It's handy for recognizing them at a glance, though it has limits: some brokers truncate it or replace it when a trade closes at the stop.
If you copy trades between accounts
Trade copiers usually assign their own magic to the replicated orders. On the receiving account, they all seem to come from the same robot.
To keep track, use one that preserves the original comment.
Frequently asked questions
What is an EA's magic number?
An integer the robot stamps on every order it opens. It lets the EA tell its own trades apart from everyone else's.
Can two EAs have the same magic number?
They can, but it's not a good idea. Their trades would get mixed up in any statistics, and one could even manage the other's positions.
What magic number do manual trades have?
Zero. That's why no robot should use that value.