Follow Several Trading Systems at the same time [Magic Numbers]

Today I am going to tell you how you can apply 100 systems at the same time and have them controlled without going crazy.

No, I do not mean that you have to apply zillions of systems to be profitable in trading. But if you use different trading systems you need to keep track of them and evaluate or supervise them.

If you don’t do this, you’re going to have open trades and you’re not going to know where the profits come from (or the slaps in the form of losses).

If you apply EAs (Expert Advisors, I explain it better in this article), you will see that it is quite simple through Magic Numbers. I’ll explain.

1. What are Magic Numbers?

A Magic Number or Magic Numberis a unique number that is associated by the expert advisors to each order that is sent to the broker and thus be able to track all open positions and differentiate them from the rest of the open orders at that moment in the same account.

This magic number makes it possible for each system to know which open positions it should manage and which not.

In the case of MetaTrader4, trades opened by even EAs can be assigned magic numbers ranging from 0 to 2147483647. However, an EA’s Magic Number must be non-zero since this is the default value of all trades. the orders. This means that manually opened orders have a magic number equal to zero, since they are not assigned any magic number. Now I will explain how to use them.

2. How to correctly use Magic Numbers to follow various systems

Magic numbers are truly magical trade identification tools when trading two or more EAs on the same currency pair, but on different time frames. Suppose you are trading GBP/USD with two different EAs, one trades 5 min candles and the other 1 Hour candles. In my personal experience I can assure you that each EA should manage open trades differently for each time frame, for example: take profit or stop loss. This is where the magic numbers work their magic.

EAs use a function called OrderSend (MQL language) to open or send a trade to our broker. This function has several parameters, but it is the OrderMagicNumber variable that assigns a unique number to each operation when it is opened.

Continuing with the previous example, we can assign a MagicNumber equal to 1 to the EA that will operate with 5-min candles and a MagicNumber equal to 2 to the EA that will operate with 1-hour candles. In this way, all the operations opened by an EA will have a unique identifier number equal to 1 and the operations opened by the other EA a unique number equal to 2.

Then when the EA wants to select or choose an order, it will use the OrderSelect function with the previously assigned OrderMagicNumber variable in OrderSend to manage the orders.

Now, surely you will ask yourself, where do I have to do all this? Expert advisors are files with an .ex4 or .ex5 extension that usually already have this magic number assigned to them, which we can also assign when we install it. How?

To use an EA you just have to add it to the asset chart and time frame where it will be executed, set a magic number and that’s it.

I’ll explain it to you in detail.

In the browser window of the MetaTrader platform we can see the EAs that we have installed on our platform.

Right-clicking on them will open a pop-up menu where we must select the “Attach to chart” option that will take us to another window that will ask us to enter the input parameters that the trading system needs to start trading, including the Magic_Number.

We can also modify the code of our strategy by right clicking on it and selecting the “Edit” option, this will take us to the MetaEditor window. Of course, I do not recommend changing anything in the code if you are not a developer.

3. System monitoring platform

Once all the trading systems are installed, comes the easiest part. Monitoring.

You will be thinking about what the hell to do once your EAs have been executed. Do I write them down on a piece of paper? Do I make a thousand excel tables? Nothing of that.

There are platforms to monitor your systems by connecting your account, filter by Magic Numbers and see for each one the number of operations, the profit or loss generated…

In this image I show you how you can do it in a simple way with FXBlue. You can also do it with Myfxbook or some extension for Metatrader.

4. Conclusion

Although using code may seem somewhat complicated if you are just starting out, MetaTrader is an easy-to-use platform and you just need to practice.

With EAs you can test many strategies at the same time in the same account, 24 hours a day from Monday to Friday.

Although there are other ways to keep track of your systems, using Magic Numbers is the most comfortable and simple way to do it.

Keep in mind that the main objective of using Magic Numbers is to simplify and control our operations. Please, do not forget to test any strategy before applying it on a real account.

I tell you in comments.

Leave a Comment