Skip to content
All library documents

Using Magic Numbers to Coordinate Multiple Expert Advisors

Article MQL5 articles

Summary

The article describes using MQL5 order magic numbers as identifiers that let multiple Expert Advisors distinguish trades on the same instrument. Rather than assigning an arbitrary small integer, it proposes encoding structured information such as an EA identifier, instrument, and relationship to other EAs within the available integer value. This can support coordinated systems spanning several charts or instruments.

A moving-average example shows a basic EA opening and reversing positions, then extends the design toward identifying positions created by different EAs. The author reports that three EA instances with distinct magic values ran without conflicts, using terminal output as evidence. The example is illustrative rather than a controlled test, and the article does not define a formal encoding scheme or address all account and position-management edge cases. Its central contribution is an organizational technique for trade identification, not a standalone trading strategy.

Key ideas

  • An order magic number can identify which Expert Advisor created or manages a trade.
  • Structured identifiers can encode more than a simple EA number, including instrument or coordination information.
  • Distinct identifiers help multiple EAs manage activity on one instrument without confusing their trades.
  • The moving-average example demonstrates order submission and reversal logic alongside identifier use.
  • The reported multi-EA run is a practical demonstration, not evidence of general reliability across setups.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.