Magic Number
Platforms & ToolsThe integer an expert advisor stamps on its own orders so it can tell its positions from manual trades and from another advisor's on the same symbol.
A magic number is an integer an automated strategy attaches to every order it places, so that it can recognise its own positions afterwards. MetaTrader gives each position a ticket assigned by the server, but nothing in that ticket records which program opened it, so an expert advisor scanning the terminal has no other way to tell the trades it is responsible for from manual trades or from those of a second advisor running on the same symbol.
It starts to matter the moment more than one thing is trading an account. Two advisors sharing a symbol with the same magic number — or with none at all — will each treat the other's positions as its own: closing them, moving their stops, or double-counting exposure when deciding whether to open another. Assigning a distinct number per strategy, and per symbol where one strategy runs on several, is what keeps each one's position count, risk check and reporting correct. It is also what makes a trade's origin recoverable from the account history months later, when the only remaining question is which system produced a particular loss.