Technological advancement has proven to be one of the contributing factors to the increase in trading. Since everything can be done online, many traders and brokers are giving trading a chance. You can remotely trade from any part of the world. Online trading had simplified the process, to begin with, but the coming up of the MetaTrader platform made trading even better.
As a platform, the MetaTrader has simplified trading by eliminating emotions. The Expert Advisors allow traders to make rational decisions by focusing on ‘what is’ rather than ‘what can be.’ Along with Expert Advisors, the MetaTrader platform also gives you expert magic numbers. Let’s explore what an expert magic number is in the MetaTrader platform.
What is the MT4 Expert Magic Number?
The expert magic number represents the MetaTrader concept to track open positions generated by the Expert Advisor. Using an expert magic number, EA can mark each position by number and distinguish the opened trades versus trades that did not open. The expert magic number can be any unique number, and they are license plates for EAs.
The MT4 platform generates a magic number employed by Expert Advisors (EA) to track open positions. This allows the EA to manage trades in a better way. Still, confused? Let’s make simplify it – equate a magic number with a driving plate. The latter allows the authority to identify the state from where the vehicle has come from and know about the exact individual who owns it. The expert magic number does a similar job. It helps the EA differentiate between the trades that have been opened by it to the ones that it has still not opened. This analysis allows the EA to manage the account in a better way.
Using a MetaTrader Magic Number
Many traders use the same Forex pair to trade across multiply timeframes. If you are one such trader, you wouldn’t want to employ an EA to track one currency pair across different timeframes. For example, consider a situation in which you are trading GBP/USD in two ways, one using an hour chart and the other on a 15-minute chart. You will need two EAs to track these two different time frames. Here, the first EA will be trend following as it is tracking the one-hour chart and the other one is scalping as it is chasing a 15-minuet chart. It is clear from the example that you should manage trades differently when you are using different timelines.
The above example is a testimony that, along with your general stop-loss exits and takes profit, you need to run channel stops for one trade and trailing stops for the other. In such cases, you will end up in a chaotic mess if you use only the currency pair to identify different trades because the currency pair is standard across the channels. It would help if you had something that stands apart.
Your bulletproof savior in the above situation is a MetaTrader magic number. The platform assigns a specific number to each trade as soon as it is opened. The EA will now follow these unique numbers instead of the currency pair to track the trade. For example, the trend-following EA may follow the 214 magic number, while the other EA might chase the magic number 316.
Thus, we can conclude that you can use these magic numbers to separate orders across different timeframes and strategies, especially when using the same currency pair. It makes EA more operational by allowing it to use its potential.
Finding a Magic Number for an Open Trade
The magic number for the trades that are opened manually is zero, but the trades that are opened on the MT4 platform, using an EA, are assigned unique numbers that can range from 0 to 2147483647. These numbers can help you in finding open trades. Let’s see how.
The MQL language uses OrderSend to open a trade. OrderSend is a function that is based on multiple parameters, the magic parameter being one of them. When a trade is opened by an EA using this function, a magic number is automatically assigned to the trade, known as OrderMagicNumber. Doesn’t it sound simple? The truth is, it isn’t a straightforward path when you employ this function for the first time, but it certainly gets easier with time. The more you use it, the more familiar you get with it.
All you need to do us to run OrderMagicNumber in an order selection loop. Select a trade by suing OrderSelect. This will allow you to run the OrderMagicNumber for your chosen trade. Once your trade has been assigned a magic number, you can put trade exits using the ‘if-then’ logic. It is a fairly easy technique to understand. For example:
- If my magic number is equal to 197, run a trailing stop.
- If my magic number is equal to 303, run a channel stop.
MT4 is a user-friendly platform that various brokers offer to their clients. Its codes are not as complicated as compared to other platforms. Yes, it does take some time to get used to it, but such is the case with anything new that you use. Along with EAs and magic numbers, it has various other features to maximize your profits.