What Is Magic Number in Expert Advisor Settings

Hello, trader friends! Very often, in the descriptions of forex expert advisors settings, you can come across the concept of Magic Number (or simply magic in the slang of forums). What is it? How do you configure magic number? What does it affect? All of this is covered in our lesson.
Ordinary users very often have many questions about this parameter. By combining these questions into one small article, I decided to help you clarify some tricky points.
Below you will find the most popular questions that may arise for both beginners and experienced traders.
What Is Magic Number?
Magic Number is a numerical identifier that an expert advisor uses so it does not confuse its own orders with someone else's. It is needed so that the expert advisor does not touch the orders of other experts, as well as positions opened manually.
The expert advisor assigns a specific code to its orders. This allows it to distinguish all the positions that are currently in the terminal and work only with the orders that it opened itself.
With the help of Magic Number, the expert advisor understands which orders are its own and which orders belong to others.
The number can be absolutely anything except zero.
Do You Need to Change Magic Number When Installing the Same Expert Advisor on Different Pairs?
Suppose you have an expert advisor that you would like to install on the EURUSD and GBPUSD currency pairs. To do this, you open two different chart windows and attach the expert advisor to each of them. Then a logical question arises:
Do you need to change the parameter so that these experts do not get confused?
There is no need to change Magic Number if the currency pairs are different!
If we place the same expert advisor on different pairs, this parameter does not need to be changed.
What If I Want to Install the Same Expert Advisor on 2 Charts of the Same Currency Pair, but with Different Timeframes?
Imagine that you placed the expert advisor on the M15 timeframe. And exactly the same expert advisor, but on the H4 timeframe.
In this case, the Magic Number must be different in the settings of this expert advisor.
Otherwise, it will start confusing the orders and thus opening and closing them on different timeframes.
Therefore, if for some reason you want to install the same expert advisor on two charts of the same currency pair, but with different timeframes, then in this case you will need to change the expert advisor settings. So that the numerical values of the parameter do not match.
What Will Happen If 2 Different Expert Advisors Have the Same Magic Number?
If two expert advisors suddenly have the same value set, then they will start confusing each other's orders.
Suppose we have expert advisors "X" and "Y" with the same numerical magic number parameters. Expert advisor "X" opens some order, and expert advisor "Y" thinks that this is its order and begins to manage it according to its strategy. And if the strategy of expert advisor "Y" says that the order must be closed, then it will close the order of expert advisor "X".
And all because their Magic Number parameters match.
Therefore, so that one expert advisor does not confuse its own orders with another's positions, this parameter must not match. They must be different.
There Is No Magic Number in the Robot Settings, Will It Avoid Confusing Orders?
Sometimes it happens that there is no Magic Number parameter in the expert advisor's settings. This does not mean that it is absent from the advisor. It is in the code. The authors of the advisor simply did not want to provide the ability to edit it.
You can use such an advisor because it will not confuse its own orders with someone else's. Its Magic Number is hidden in the code and preset by the developers of this advisor.
And what Magic Number do manual trades have?
Manual trades have a Magic Number of zero. That is why this parameter can be any number except zero. When opening manual trades, you do not assign any identifier. There is no such option in the terminal, but in essence it is not needed.
If you want to use some auxiliary expert advisor that will modify orders you opened manually, then you will need to set zero in its magic number parameter.
That's all from me.
I hope I was able to help you understand this parameter, which will be useful in your Forex trading.
Respectfully, Pavel Vlasov
TradeLikeaPro.ru
<p>Hello, trader friends! Very often, in the descriptions of <a href="https://tlap.io/ru/baza-znaniy?cat=forex-advisors" target="_blank" rel="noopener noreferrer">forex expert advisors</a> settings, you can come across the concept of <strong>Magic Number</strong> (or simply magic in the slang of <a href="http://forum.tradelikeapro.ru/" target="_blank" rel="noopener noreferrer">forums</a>).</p>