Expert Advisor Magic Number Explained (MT5)

What a magic number is, why every MT5 EA needs its own, how to set it, and how to fix conflicts when several advisors trade one account.

· Guides

A magic number is the ID an MT5 expert advisor stamps on every order it opens. The terminal uses it to answer one question: is this position mine?

Why it exists

MT5 accounts are shared space. Manual trades, two or three advisors and a trade panel can all place orders on the same symbol. Without an identifier, an EA managing "all XAUUSD positions" would happily move the stop loss on your manual swing trade or close a different robot's basket.

With a magic number, each EA filters positions by its own ID and ignores everything else.

Situation Same magic number Different magic numbers
Two EAs, one symbol They fight over positions Each manages its own
EA + manual trades EA may close yours Manual trades untouched
Reporting per strategy Impossible Clean per-EA stats

How to set it

  1. Attach the advisor to a chart and open Inputs.
  2. Find MagicNumber (sometimes Magic, EA ID or InpMagic).
  3. Give every advisor — and every chart, if you run the same EA on several symbols — a unique integer.
  4. Write the numbers down. A simple scheme works well: 1001 gold, 1002 indices, 1003 crypto.

Rules of thumb:

  • Never reuse a number across two running advisors.
  • Do not change the magic number while positions are open — the EA loses track of them and stops managing those trades.
  • If you must change it, close or manually manage the existing positions first.

Typical problems and fixes

Two advisors closing each other's trades. They share an ID. Stop both, assign unique numbers, restart.

The EA stopped managing an open trade. The magic number changed (new preset, reinstalled EA, different chart). Handle that position manually, then keep IDs stable.

Positions appear with magic 0. They were opened manually or by a tool that does not tag orders. Most EAs deliberately skip them.

Duplicated orders after a terminal restart. Check that the same EA is not attached to two charts of the same symbol with the same ID.

Magic numbers and licensing

Some vendors bind a licence to the magic number, which breaks the moment a client edits the input. At EA Quantum Lab, a licence is validated by trading account number only — your magic number is free to change for order management without touching activation. See the activation guide and the settings reference.

Quick checklist

  • One unique integer per running advisor.
  • Documented list of which number belongs to which strategy.
  • Never edited while trades are open.
  • Used for per-strategy reporting in your journal.

Get this right once and multi-EA portfolios become boringly reliable — which is exactly what you want. Browse tested advisors in the marketplace.

Continue reading

Failed to load the app

Something went wrong while loading. Try reloading the page — if the issue persists, clear your browser cache (Ctrl+Shift+R).