Magic numbers in forex trading.

Justin Iheakanwa
89
Justin Iheakanwa  

The magic number is a MetaTrader concept used to track the open positions of an expert advisor. The concept allows the EA to distinguish the trades that it opened versus those that it did not.Every car has a license plate. When you see a car in a different state or even a different country, you know that every plate that you see is unique. The police can look up the number to determine who owns the car.Magic numbers act like the license plates for EAs. When an expert advisor reads an open trade, called a ticket, it often requests its magic number. If the magic number of the ticket matches the number that the expert advisor expects, then it knows to manage the trade.Magic numbers are useful, particularly when you want to trade multiple time frames of the same currency pair. Traders often use settings that differ on M1 charts versus those that would use on the D1. If they applied the EA with the same magic number on all charts, the result would be chaos. The expert advisor would open and close trades at random. Setting each EA to use a different magic number prevents the robots from interfering with the others.


... Guys what's your take on magic numbers in forex trading?

Sergey Golubev
Moderator
120133
Sergey Golubev  
  • MQL5 Reference → Standard Library → Strategy Modules → Base classes for Expert Advisors → CExpert → Magic  
  • MQL5 Reference → Standard Library → Trade Classes→ CPositionInfo → SelectByMagic

----------------

----------------

MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
  • www.mql5.com
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5