Source code
MT5 Magic Number: organise multiple Expert Advisors
A Magic Number is an identifier attached to trading activity by an EA. A good naming plan makes a multi-chart workspace much easier to understand and troubleshoot.
Use an identifier with a purpose
In the MQL5 Standard Library, SetExpertMagicNumber sets the expert identifier used by a CTrade instance. The number is not a password, activation key or exclusive reservation. Another program can use the same value; isolation depends on the code checking ownership correctly.
Give each strategy instance a clear identity
Create a small register containing EA name, version, chart symbol, timeframe and Magic Number. If the same strategy runs on two charts, use distinct identifiers when its design supports that separation. Preserve any reserved ranges documented by a multi-strategy EA rather than assigning arbitrary overlapping numbers.
Filter before managing a position
Source readers should find the position-selection logic before changing the identifier. Look for symbol and ownership checks, and whether modifications address a specific position ticket. On a netting account, strategies trading the same symbol can affect one combined position; different Magic Numbers do not create separate netting positions.
Verify with a small demo experiment
- Run two clearly labelled instances on demo charts.
- Inspect their orders, deals and positions after a signal.
- Confirm that an exit or trailing action touches only its intended scope.
- Save the identifiers with the presets so a restart does not create confusion.
Make it yours with MQLume
MQLume source access lets you understand how a project identifies and manages its trades. Explore the parameter guide for Quantum Commander MT5 before planning a multi-strategy workspace.