Expert advisors explained
Discover how to automate your MT4 with Expert Advisors, the ‘forex trading robots’ that can help you start algorithmic trading.
What are Expert Advisors?
Expert Advisors (EAs) are programs that run on the MetaTrader 4 (MT4) platform, used to monitor and trade financial markets using algorithms. They find opportunities according to the parameters you set, then either notify you or open a position automatically. And once your position is open, an EA can add close conditions including stops, trailing stops and limits.
You could, for example, use an EA to monitor a few key markets. It would alert you when it finds a potential opportunity for profit. Equally, you could let it loose on the markets completely, opening multiple positions each day with little human input.
For most traders, EAs are primarily used for forex trading. But you can use them to trade any market that’s available on your MT4. If you’re an IG client, for example, you can use an EA to trade forex, indices and commodities on an enhanced MT4.
How do Expert Advisors work?
EAs work by enabling you to set the parameters by which opportunities are found, and positions are opened and closed – essentially using a set of yes/no rules to trigger trading decisions. You can either build an EA for yourself, or import one that someone else has built.
By combining lots of yes/no rules into a complex mathematical model, EAs can execute sophisticated trading strategies, using computational power to make decisions – and act on them – almost instantly.
Expert Advisor example
A simple EA could monitor one or two markets, notifying you about potential trades when set conditions are fulfilled.
Let’s suppose that you wanted an EA to spot any mean reversion opportunities on GBP/USD using the 20-day simple moving average (SMA) indicator. You could import one that someone else has built, or you could build one yourself using a programming language called MQL4.
You’d program your EA to monitor GBP/USD constantly and notify you if the pair breaks out of its 20-day SMA. You could also program your EA to act upon the opportunity instead of just notifying you, for example, by using 2% of your total available balance as the size of the position. From there, how complicated your EA gets is entirely up to you.
Why are Expert Advisors popular?
A correctly-programmed EA can monitor hundreds of markets, meaning you don’t have to watch price movements 24 hours a day in order to find new opportunities. With an EA in place, you can decide how much time you want to dedicate to the markets - you could use an EA for trading alerts but open and close positions yourself, or allow it to open positions on your behalf and merely keep an eye on your running profit or loss.
Emotion can affect your bottom line. It might encourage you to hold on to a losing trade for longer than you should because you don’t want to realise the loss, or dive into a reckless trade too quickly, riding high off a big win. Automating your trading helps take the emotion out of your decision-making because an algorithm only views the markets in black and white.
Your EA can run on any market that you can trade using MT4, taking lots of information into account including price movements, economic announcements, technical indicators or even your current available balance. The ability to build hugely sophisticated algorithms that track many different markets makes EAs a powerful tool to support your trading.
Building a strategy is just the beginning as trusting it to take care of your capital is a big step to take. That’s why most traders will backtest their EA before letting it loose on live markets. Backtesting involves running your strategy against a chunk of real historical data and seeing how it performed, helping you to iron out any issues before they end up losing you real money.
However, it’s important to note that backtesting isn’t completely foolproof. For example, slippage can’t affect your trades when backtesting, but it can be an issue once you start using your EA on the live markets.
While they are all undoubtedly major benefits, in truth the above four points apply to any automated trading system – not just EAs. However, while building a trading algorithm from scratch can be complicated, importing an EA just means choosing a program and tailoring it to your needs. The easy accessibility of EAs is probably the biggest reason for their popularity as an automated trading tool.
But while a well-coded, fully backtested and properly monitored EA can be hugely beneficial to your trading, there are some major pitfalls to avoid.
Risks of Expert Advisors
If the promise of a program that beats the returns of the world’s best fund managers at a fraction of the cost sounds too good to be true, then it probably is. So, if you’re planning on buying a readymade EA, it is imperative that you carry out your own research to make sure that what you are buying is worth the money.
Lack of human interaction
No matter how sophisticated your EA is, it’s no match for the human brain. As such, it is important to remember that while taking some of the emotion out of your decision making is often useful, removing it entirely can bring new problems. It is always important to keep track of how an EA is performing and assessing whether it is in line with your trading logic.
Not always online
Unlike a web trading platform, to run MT4 you have to install it. This means that you can only access it from the device you install it on, and your EAs can onlyrun when that computer is switched on, with MT4 up and running and connected to the internet.
If you want your EA to run round the clock, you’ll need a virtual private server (VPS).
What is a virtual private server (VPS)?
A VPS is an online version of your MT4 that is hosted on an external server, enabling your EAs to operate even when your computer is switched off. It solves the problem of needing your computer or mobile device to be running MT4 in order for your EA to function, by hosting an instance of your MT4 on an external server that is always on.
For more information about IG’s VPS service, contact our helpdesk at email@example.com, or call us at 0800 195 3100.
How to get started with Expert Advisors
You can build your own EA or download one that someone else has already built. Whichever way you choose to begin using an EA, it will need to be backtested to ensure that it works in the way you expect before letting it trade with real funds.
Build an Expert Advisor
EAs for MT4 are built using a programming language called MetaQuotes Language, or MQL. Just like any programming language, getting up to speed with the ins and outs of MQL requires a significant investment of time and effort. You can find guides on the MQL site.
You can also build simple EAs using MT4’s inbuilt wizard, or an external strategy-building tool. These visualise the code that is being written underneath, enabling you to put together strategies without having to learn the programming language itself.
Use a pre-built Expert Advisor
If you have found a pre-built EA you want to use on MT4, you’ll need to copy it into the ‘experts’ folder where your MetaTrader 4 is installed on your computer. On a computer, this is usually located on the ‘c:’ drive.
Once that’s done, launch MT4 and expand the ‘Expert Advisors’ section on the left hand side. Your EA should be located there. Drag it onto a chart to get started, and you’ll be asked to review its settings before putting it live.
Backtest your Expert Advisor
You can backtest an EA on MT4 using the strategy tester, which you’ll find by clicking ‘view’ in the top navigation bar. In the tester, select the EA you want to run, as well as the market and timeframe you want to run it against. Backtesting an EA is important to ensure that it is working currently.
EAs can also be run on a demo account within MT4. Just install the EA in exactly the same way as on a live account, and set it running on your chosen markets. With an IG MT4 demo account, you’ll be able to trade on over 80 markets using £10,000 in virtual funds, and test some of the free indicators and add-ons that are available on our live platform.
Publication date :
This information has been prepared by IG, a trading name of IG Markets Limited. In addition to the disclaimer below, the material on this page does not contain a record of our trading prices, or an offer of, or solicitation for, a transaction in any financial instrument. IG accepts no responsibility for any use that may be made of these comments and for any consequences that result. No representation or warranty is given as to the accuracy or completeness of this information. Consequently any person acting on it does so entirely at their own risk. Any research provided does not have regard to the specific investment objectives, financial situation and needs of any specific person who may receive it. It has not been prepared in accordance with legal requirements designed to promote the independence of investment research and as such is considered to be a marketing communication. Although we are not specifically constrained from dealing ahead of our recommendations we do not seek to take advantage of them before they are provided to our clients. See full non-independent research disclaimer and quarterly summary.
You might be interested in…
Find out what charges your trades could incur with our transparent fee structure.
Discover why so many clients choose us, and what makes us a world-leading provider of spread betting and CFDs.
Stay on top of upcoming market-moving events with our customisable economic calendar.