What Is Magic Number in Expert Advisors?

What Is Magic Number in Expert Advisors and Why They Matter?

Magic number in forex EA

There are many factors and variables that tie into automated trading and the use of expert advisors. For instance, matters related to risk management, the trading strategy, and many other things. But there is one thing that you might have heard less of, and it is known as magic numbers. The notion of magic numbers is extremely important for EA trading

Magic numbers can help traders manage their trades much better and more smoothly with unique identifying numbers when using expert advisors. Now that you are intrigued enough to find out what these magic numbers really are, let’s dive right in and find out everything about magic numbers with expert advisors. 

 

What is a Magic Number in an Expert Advisor?

 

Very simply put, a magic number is a unique identifier in the environment of an expert advisor that is assigned to each single trade or any open position by the expert advisor. This system of coding using numbers is usually chosen based on the preference and discretion of the developing team behind the expert advisor. 

The reason they are called magic numbers and we previously referred to them as unique identifying numbers is that such numbers are specifically used for identifying. More specifically, they are used for identifying which trades or positions are opened by which expert advisor. 

Magic number in EA

 

An account might be using more than one expert advisor, in fact many more, at any one time. One main advantage of these numbers is that they can help you identify which expert advisor is responsible for which position. So, it is kind of like these are tags that are put on positions to show which EA is in charge of them. 

Now imagine there were no such things as magic numbers and we had to trade using expert advisors without them. What would happen? In that situation, there would be no way to find out which expert advisor has opened which position. And when we are faced with a number of positions, then we are faced with a mingled and mixed situation where we do not know which expert advisor is working well and which one is not optimal for our conditions. 

But when using these numbers, not only can you manage your expert advisors better, you can single out trades and make adjustments to specific EAs without having to redesign or redefine your entire trading approach. 

 

Why Do Magic Numbers Matter in Automated Trading?

 

As we discussed shortly in the previous section, magic numbers play a crucial role when it comes to trading with expert advisors. Their role is one of management and keeping track of everything in the process of trading. But there is so much more that they can do for traders, such as the points that are as follows: 

 

  • Trade Identification and Tracking

First and foremost, magic numbers help us identify and be able to track the orders that are placed by expert advisors. This is because each position or order is tagged so-to-speak with a magic number that is specific to the expert advisor behind it, thus allowing the trader to track the position easily and trace it back to the EA which opened it. Do consider that this becomes quite consequential when dealing with multiple positions and trades at the same time. 

 

  • Avoiding Conflicts with Manual Trades

More often than not, especially when it comes to more seasoned and experienced traders, we see that the trader in charge of the account is using expert advisors but also executes traders manually. In account where we have both automated and manual trades happening alongside each other, the matter of position and trade management becomes that much more important. In these cases, it is very easy for manual and automated trades to be mixed up with each other. 

When there are manual positions open as well as automated ones, then the automated system might also interfere with them. For instance, the expert advisor might just close those positions as well. But if there are magic numbers involved with them, then all the EA positions are tagged, and it will only involve those positions in its operations. 

 

  • Enhanced Portfolio Management

The ultimate goal of any trading account must be obtaining an ideal degree of diversification. Using a single expert advisor or trading a single currency pair cannot lead to quite as optimal results as could potentially be fully attainable. So, diversity is key. A truly diversified automated account is one that employs multiple expert advisors to achieve the most ideal results of automated trading.

In this case, there is almost no other way to manage all these different expert advisors aside from using magic numbers. In this type of situation, magic numbers will allow every single expert advisor to run its own trades and positions smoothly and without interference from other EAs. 

 

  • Enabling Multiple Strategies in a Single Account

Another important benefit of expert advisors having magic numbers is that they can help you run multiple trading strategies at the same time. This is really difficult otherwise. Many traders will have to resort to having multiple trading accounts for multiple trading strategies. But with the help of magic numbers, you can use the same trading account and implement various trading strategies through multiple expert advisors. And all of them will be able to run smoothly because of these unique tags that are accompanied with every one of these positions. 

 

  • Troubleshooting and Debugging EAs

Of course, aside from being able to track and manage all the different trades and positions opened by the expert advisors on the same trading account, magic numbers will also help immensely with the process of troubleshooting and ultimately debugging the EAs. Because each position has this magic number with itself, you can easily see which ones are doing well and which ones are not doing so well. Thus, you can trace back the ones that are resulting in loss and find the expert advisor in charge. Subsequently, you can use that information to troubleshoot and optimize the expert advisor in charge for an enhanced experience of automated trading. 

 

How Are Magic Numbers Assigned?

 

So, at this point in the article, you might be wondering who is in charge of assigning these magic numbers. Magic numbers are chosen by the developing team behind the expert advisor or by the user when they are first being set up in the MetaTrader 4. Basically, magic numbers can include any number as long as it is an integer. And the way they are chosen ought to be in such a way that it is easy to follow and track. 

You can also pick them based on different categorizations for the trading process that you have set up. For instance: 

  • For individual strategies: you can choose your numbering system based on the different trading strategies that are offered by different expert advisors. For instance, you can label those EAs that run on scalping as 100 and those that run on swing trading as 200, so on and so forth. It is ultimately up to the user. 
  • For different timeframes or asset pairs: the categorization based on numbers can also take place for more detailed classes and types. For instance, you can number them based on the different timeframes or based on the different currency pairs or other assets that are being traded. 

Best Practices for Using Magic Numbers

 

  • Assign Unique and Consistent Magic Numbers for Each EA

First and foremost, the number that you assign to each expert advisor should be unique from the other numbers that you use for other expert advisors. This kind of goes without saying, but you can see how using the same number for more than one expert advisor could simply render the whole idea of magic numbers ineffective. 

And just to make sure this type of repetition in using numbers never happens, it is recommended that you refrain from reusing any number that you have previously used for an expert advisor. 

 

  • Use Descriptive Numbering Systems

You can come up with a system of numbering that is creative and also descriptive. For instance, you can define the set of numbers such that the first digit shows the respective market, the second number defines the specific expert advisor, the third defines the trading strategy, so on and so forth. 

For example, number 247 can be quite meaning given the following system: 

In this system 2 refers to the forex market 

Number 4 refers to the X expert advisor 

And number 7 refers to the scalping trading method 

 

  • Regularly Check for Duplicate Magic Numbers

Lastly, make sure to always check that there are no duplicate and repetitive numbers or sequence of numbers in your magic numbering system. This is part of the regular maintenance that you need to keep up to effectively implement magic numbers for expert advisor management. 

 

Magic Numbers in Backtesting and Optimization

 

Lastly, a rather unique and important function of magic numbers is that you use this system for the purposes of backtesting and the subsequent optimization of expert advisors. This is because this system will allow you to tag each expert advisor and even trading strategy and thus be able to track them perfectly well and see which one is doing well and which is doing poorly. 

You can then single out the expert advisor that is in particular need of optimization and further adjustment for better and more enhanced performance. After optimization, you can reenter the expert advisor into your trading account and continue keeping track of it using its magic number to see how it is doing. You can do the same with all the other expert advisors that you are implementing in your trading account. This is how magic numbers can help you in every aspect of expert advisor management. 

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen + 14 =

×