todobion.blogg.se

The magic number
The magic number










  1. THE MAGIC NUMBER MANUAL
  2. THE MAGIC NUMBER PRO
  3. THE MAGIC NUMBER CODE

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.

  • Separate orders opened by different expert advisors.
  • Separate orders for the same instrument but based on different timeframes.
  • Separate orders originating from different strategies.
  • When you automate your trading through MQL4, using a magic number is necessary to select which orders to work with. As your experience grows, you may increase the number of open orders or strategies that you are using at the same time. Why Use Magic Numbers?Īt the start of your trading journey, you probably deal with only one or few orders at a time. Of course, you could generate a different magic number for each order, but this wouldn't be helpful as you will see in the next section. The same magic number can be used in many orders. Basically, when you open an order in MetaTrader 4 using MQL4 code, you can associate the order to a number. It is important to be able to manage the different orders running under different strategies and that is why you need a magic number!Ī magic number is an identifier for the orders. When working with scripts, indicators, and expert advisors in MetaTrader 4, you may arrive to a stage where you manage many orders at the same time. A magic number is an identifier that you can assign to an order in MetaTrader 4 using the MQL4 language.












    The magic number