Thinking the magic number affects execution
It changes nothing about how an order fills. It is metadata: the broker does not act on it and it has no effect on price, spread or slippage.
An integer an Expert Advisor stamps on every order it sends, so it can recognise its own positions and leave everything else on the account alone.
also: Magic, EA identifier, MagicNumber
Updated · Reviewed
A name tag on every trade. The terminal does not care who opened a position, so each EA writes its own number on the ticket and then only touches tickets carrying that number.
MetaTrader gives every EA on an account the same view of every position. Without a tag, an EA cannot tell its own trades from yours or from another EA's — and an EA that manages the wrong position is a bug that costs money rather than one that throws an error.
| Setting | Typical value | Note |
|---|---|---|
| Manual trades | 0 | The terminal's default. An EA should never manage magic 0. |
| One EA, one symbol | any unique integer | Anything memorable works — 20260807, 1001. |
| Same EA on several symbols | one value per chart | Otherwise the EURUSD instance closes the GBPUSD instance's positions. |
| Portfolio EA running several strategies | one value per leg | Each leg needs its own tag to be trailed and closed independently. |
Three EAs on one account. Each stamps its own number, so each position loop touches only its own rows even though all of them see all six positions.
Calculation if (PositionGetInteger(POSITION_MAGIC) != MagicNumber) continue;
Result Each EA manages only the positions it opened
Illustrative figures — not the record of any listed EA.
Treat the magic number as account configuration, not as a strategy setting: write it down before the EA goes live, and never change it while positions are open.
The value itself has no meaning to MetaTrader — any integer works. All that matters is that it is unique among the things running on that account.
It changes nothing about how an order fills. It is metadata: the broker does not act on it and it has no effect on price, spread or slippage.
The identity that matters is the running instance, not the product. Two charts sharing a tag means two instances managing one shared pool of positions.
The open positions keep the old tag. Changing the input abandons them: the EA stops recognising them, and they stay open until closed by hand or by a stop out.
The terminal's Trade tab does not show it. Separating results per EA requires reading DEAL_MAGIC from the history, which is what reporting tools do — not something the default statement gives you.
| Across the 14 EAs published here | Figure |
|---|---|
| Listings with a MagicNumber input | 10 |
| Listings needing it changed during setup | 0 |
| Listings telling you to run them where nothing else trades that symbol | 8 |
| Of those, listings that carry a MagicNumber input anyway | 6 |
| Symbols claimed by more than one listing | 7 of 15 |
| EA pairs that cannot share one account | 15 of 91 |
Read rows three and four together. Tagging orders is one job; deciding whether a new
signal is allowed is another, and an EA that caps itself at one open position has to
count first. Count with PositionsTotal() and a symbol check and a foreign position
lands in the total; filter on POSITION_MAGIC first and it does not. Six listings here
carry the input and still print the warning, which tells you which of the two their
position count does.
So the pairing question is a symbol question, and it is answerable before you buy. USD/JPY is claimed by four listings at once — Iridescence, Kestrel Hover, Lanternfish and Tessera — so no two of them belong together, and EUR/GBP now carries two, Ballast and Thunderhead. Only Orrery, Peregrine and Zerqon overlap nobody. Where two do overlap, separate accounts fix what a tag cannot: each EA then counts a pool that contains only its own trades. Our methodology records every published run per symbol, which is the same distinction seen from the measurement side.