Trading tools

Magic Numbers in MetaTrader: What They Are and Why They Matter

2 min read Reviewed by

A magic number is an identifier an Expert Advisor stamps on every order it opens. It is how the EA recognises its own trades among everything else on the account - so it can manage, modify and close them without touching positions opened manually or by other EAs. It matters because when two EAs share a magic number, each treats the other's trades as its own, and they will happily mismanage or close each other's positions.

If you are still getting familiar with how EAs work at all, start with what an Expert Advisor is.

How it works

When an EA opens a trade in MT4 or MT5, it attaches an integer - the magic number - to the order. Later, when the EA scans the account to decide what to manage, it filters by that number: "show me only trades tagged 12345". Everything else is invisible to it. Manual trades typically carry a magic number of zero, which is why a well-behaved EA leaves your manual positions alone.

Why it matters in practice

  • Running multiple EAs. Each EA on the account must have a unique magic number, even if they trade different symbols. This is the golden rule of running multiple EAs on one account.
  • Same EA, multiple charts. If you attach the same EA to two charts, give each instance its own magic number - otherwise the copy on chart A may manage trades opened by the copy on chart B.
  • Performance tracking. Because every trade is tagged, you can filter account history by magic number and see exactly which system produced which results - essential when judging whether an EA is doing what its backtest promised. See equity curve analysis for what to look for.
  • Recovery after restarts. If the platform or VPS restarts, the EA finds its open trades again by magic number and resumes managing them.

How to set it

  1. Open the EA's properties (double-click its name on the chart, or right-click → the EA's settings).
  2. On the Inputs tab, look for a parameter named something like Magic Number, MagicNumber or EA ID.
  3. Choose any integer you like - the value itself is meaningless; uniqueness is everything. A simple scheme such as 1001, 1002, 1003 per EA instance works well.
  4. Write down which number belongs to which EA and chart. Future-you will be grateful.

Common mistakes

  • Leaving every EA on its default. Two products can ship with the same default value. Always check when adding a second EA.
  • Reusing a number after retiring an EA while old trades tagged with it are still open - the new EA may adopt and "manage" them.
  • Assuming the magic number does anything else. It is an ID, nothing more. It has no effect on strategy, risk or performance.
  • Blaming the EA for closed trades when the real cause was a magic-number clash. If trades are being closed unexpectedly, check for duplicates before anything else - and see the wider troubleshooting checklist for other odd behaviours.

One number per system

Any properly built EA exposes its magic number as an input, and EAs exported from Nebula follow the same convention - each deployed system carries its own identifier, so a portfolio of strategies can share one account without stepping on each other's trades.

Trading carries a high level of risk. Nothing here is financial advice; past performance does not predict future results.

Systems Library

Want the whole system, not just the tool?

76 complete trading systems, each tested on data it never saw, from £9.99. Buy 3 and save 15%.

See the library
Higher risk£29.99 Nebula Gold Breaker XAUUSD · M15 · Trend continuation
Unseen data+22.5%
240 test trades · worst drawdown 7.13% at 1% riskSimulated. Details
Higher risk£19.99 Nebula Callisto XAUUSD · M5 · Accumulation reversal
Unseen data+99.4%
276 test trades · worst drawdown 19.11% at 1% riskSimulated. Details
Higher risk£19.99 Nebula Halo EURUSD · H4 · Trend continuation
Unseen data+11.2%
Small sample: 83 test trades · worst drawdown 5.07% at 1% riskSimulated. Details

Start free. Deploy one system.

Download free for Windows Email me the download link
Capital at risk. Nebula is a tool, not financial advice.
Free includes one real deploy to MT5, one system, once. Paid plans from £29 a month.

Download Nebula free · What Nebula does · Funded and prop firm traders · Free trading tools · Reviews · Discord · YouTube · About · Contact

  • Free tier, no card: build, test and make one real deploy before you pay anything
  • Runs on your own PC or Mac: your MT4/MT5 account stays with your broker
  • 14-day cooling-off on any purchase before activation, in line with UK consumer law
  • A real person answers: Ross, the founder, via contact or Discord
  • Real reviews · Nebula on Trustpilot

Reviews on Trustpilot: Nebula & tools (Orion RFX) · private mentoring (Pip Surfing Society)

Official partnerNESAB Investments

Watch AI trade, right on your phone.

In NESAB, five AI models run nine simulated portfolios on live prices. Every decision is logged with its reason. Follow one or all of them.

20% off your first monthROSS20
Get NESAB

Use the code when you subscribe after the free 3 day trial.

Why we partnered ›

NESAB portfolios are simulated. Past or simulated performance does not guarantee future results.