Platform also: EA magic, order magic number, MAGIC

Magic number

A unique integer identifier assigned to each Expert Advisor orders in MetaTrader, allowing multiple EAs on the same account to distinguish their own trades from others.

Why it is required

When multiple EAs run on the same account simultaneously, MetaTrader orders have no inherent ownership marker. The magic number is written into each order by the EA at open time and read back when managing positions.

An EA that checks the position magic number before modifying a position will only touch its own trades, leaving others undisturbed.

Conflicts

If two EAs use the same magic number on the same account, each EA will manage the other EA positions — with unpredictable results. Always assign unique magic numbers to each EA instance.

Multi-instance deployments

If running the same EA on EUR/USD and GBP/USD simultaneously, use different magic numbers for each instance to prevent cross-pair order management.

Related terms

See also