
THE MAGIC NUMBER CODE
The Magic Number is asked before the code starts running. The example below shows you some code that you should include in your programs to allow you (or other traders) to specify a magic number for the code running. When you code an expert advisor or a script that opens and updates orders, I would suggest to always use a magic number. When you select an order with OrderSelect(), you can retrieve the magic number for the selected order using the function OrderMagicNumber(). So, with this function, you associate a magic number with the order you are opening. When you open an order with the OrderSend() function, one of the optional parameters is a magic number. MQL4 has native functions to assign and read a magic number. Working with magic numbers in MQL4 language is quite easy. It can also show you magic numbers of your open orders.
THE MAGIC NUMBER PRO
One-Click Trade Pro for MT4 is a free order management panel that allows you to submit orders associating them to a magic number. It is for this reason, that we created a tool that can help you significantly with this aspect of trading. However, not everyone is capable of coding or has enough time to spend on it. You can work with magic numbers when coding your own tools in MQL4 like explained further in this guide.
THE MAGIC NUMBER MANUAL
MetaTrader 4 does not allow to work with magic numbers via its normal interface for manual trading. Using two different magic numbers will allow the expert advisors to work only on their own trades. If the expert advisors are coded properly, you will be able to assign different magic numbers to the orders opened by the two expert advisors. One expert advisor is a scalper working better on a 15-minute chart, while the other one is more suitable for a 1-hour chart. To mention an example, assume you have two expert advisors and you want to run all of them on the EUR/USD currency pair.
