MagicNumber (magic number) MQL for MetaTrader

What is MagicNumber?

MagicNumber MQL for MetaTrader - is a "magic" identifier of an open order, which is most often used for correct joint work of Expert Advisors with each other or with a trader in the trading terminal MetaTrader 4.

What is MagicNumber?

What is the essence of MagicNumber?

For several trading experts or experts working in parallel with a trader to be able to correctly process orders opened exclusively by them, such orders are assigned the MagicNumber parameter.

As a result, when working (modifying, closing, deleting, etc.) with orders that are already open, EAs process only those that have this magic number.

The MagicNumber tool is characteristic only for the MQL programming language in the MetaTrader terminal.

Use Magic numbers in manual trading will not work, but this number is simply unreplaceable in expert trading.

Examples of using MagicNumber

  • Simultaneous trading of trader and advisor

Trading Expert Advisor trades according to its algorithm and must manage only its own positions, not touching the positions opened manually by the trader.

To do this, the Expert Advisor assigns its orders a unique MagicNumber, other than zero, and subsequently manages only positions in which the MagicNumber parameter corresponds to the one assigned earlier.

  • Simultaneous trading of several Expert Advisors

Each trading robot has to manage only its own orders. For this purpose, each Expert Advisor uses a unique parameter MagicNumber for its positions to distinguish its orders from "alien" orders.

These are the simplest, but not the only examples of how to use the MagicNumber parameter.

Useful articles on the topic

Leave a Reply

Back to top button