In the previous article, we touched upon the basics of algorithmic trading and how traders use these automated trading programs. In this article, you will get a step-by-step process on how to run an EA on the MT4 trading platform.
We will make use of the standard EAs that MT4 provides. We will also show you how the results can vary depending on changes to the same EA. By the end of this article, the reader should be able to comfortably navigate their way around the MT4 EA universe.
To begin with, let's take a very simple and well-known trading indicator, the moving average. The moving average as the name suggests is an indicator that continuously plots the average price, based on the closing prices.
The number you assign to the moving average shows the average number of periods in questions. To build a moving average strategy, traders make use of two moving averages. Typically, the first moving average is of a shorter period while the second moving average is of a longer period. When these two moving averages cross over each other, bullish and bearish signals are formed.
A manual trader would then wait for these signals to form and then would take a long or a short position accordingly. In order to explain how to use the MT4 EA, we will use this simple strategy and see how algorithmic trading on MT4 works.
In the first step, we will show you how to backtest an EA. Backtesting an EA simply means that you want to test the EA’s capabilities using historical data. This will give you a rough idea of the performance of the EA and the strategy it uses.
Navigating to the Expert Advisor
In the second part of this article, we will show you how you can actively use an EA for trade live for you. We should reiterate that if you are new to using EA’s then you should test it out only on a demo trading account.
There are many ways to access the EA folder on your MT4. The easiest of all is to simply use the keyboard shortcut Ctrl + R. This will open up the strategy tester for you at the bottom part of the screen.

The EA window gives you a lot of options. To begin with, change the first dropdown to Expert Advisor. Then select the EA of your choice.
To see the full list of EAs, you can select from the drop-down. Alternatively, you can use the MT4 navigator window using the keyboard shortcut Ctrl + N.
From the navigator window, select or click on the + sign next to the Expert Advisors section. This will open up a list of EAs that are currently available.
For forward testing, you simply have to drag and drop the EA onto the chart of your choice.
Adding a new EA to MT4
To add a new EA to your MT4 account, click on File from the main menu and select 'Open Data Folder.' This will open the data folder location to your MT4 installation. From this window, click on MQL4 > Experts. You can paste your EA file here.
Note that some EAs depending on their code may require additional files. These can range from additional library files (which you can paste to MQL4 > Libraries) or other supporting files which can be placed in MQL4 > Files.
In most cases, the EA installation instructions will guide you on how to manage these additional files.

Once the EA is placed in the appropriate folders, you only need to go back to your MT4 terminal and right-click on the navigation window and select Refresh. This will now refresh your files in the terminal and it will show any additional files that you have placed in the Data folder.
The example below shows that we have dropped a new EA file called EA-2MACrossover_v1-0.exe into the Experts folder.
After refreshing, we now have this EA in our navigator window. So we will use this EA to backtest on EURUSD. This will also show up in the drop-down in the strategy tester window.
Initial set up of EA for MT4 Backtesting
Going back to the EA or the Strategy Tester window, you can select the EA of your choice. The next step is to select which Symbol to use this EA on. Then, we need to select the period for which you want to test the EA on.
This again depends on what and how the EA is made for. There are some expert advisors that are created to trade on a specific time frame. For the purpose of this article, the free EA we are using can be used in any time frame. Hence, we will select the daily chart time frame.
You can leave the rest of the settings as is if you want to. For example, the Spread is set to the current spread by default. It will make use of the current spread that is applied.
We now move into some advanced settings.
The model allows you to choose from Every tick, control point and open price. The last two options are not optimal for a backtest. Hence, we should select every tick.
The next sections below this allow you to select the period of backtesting. Using the date icon, you can set it to any start date and end date of your choice. We will select a period of five years for our backtesting.
Finally, the visual mode, if checked will play out the EA in a new chart window. Here, you can see the real-time trade execution. Note that using visual mode will slow down the backtesting. Therefore we recommend that first, you execute your EA without visual mode to get the results and then re-run it again with visual mode on to see how it works.
Downloading historical data for MT4
While we are almost ready to run the backtest, the biggest requirement is having a good history. If you have never downloaded historical data, then this section is for you.
An EA is only as good as its strategy and the historical data it uses. Therefore it is important that you first check that you have downloaded the historical data. To do this, go to Tools in the main menu and select History Center.
You can also use the F2 shortcut key to open the history window. The history window shows you the list of instruments and their data that is available. Usually, if you do not have historical data, the icons are greyed out.
To download the data, just double click from the 1 Minute up to Monthly to download full historical data. Since we will use our EA on the daily time frame, a good way to check if you have all the data you need is to click on the time frame in question in the history window.
If you see that the data is not sufficient, you can select the time frame and then click the Download button. This will download the historical data for the symbol and the time frame. Note that the amount of historical data may vary depending on your broker.
Once the data is downloaded, this is what you will see. Notice that in the below picture, we can use the scroll bar on the right to see the earliest available data we now have for the daily chart timeframe.
We now have a good enough history for us to backtest our EA.
Configuring the EA properties
Now that we have the historical data downloaded, the last step before we run our EA is to configure its settings or properties. Every EA has its own set of customizable parameters. Go back to the strategy tester window and click on the Expert Properties button.
This opens a new window. Since we are using the simple moving average EA, there are not that many settings to configure. The first tab enables you to enter a fictional trading balance and whether the EA should trade long, short or both directions.
We will choose a starting balance of $5000 to make it more realistic and allow the EA to trade long and short.
You can leave the rest of the settings under optimization to their default settings. Then click on the Input tab where our main focus is on changing the moving average settings.
You can select any number you want. For our experiment, we will use the 20 and 50-period moving averages under the value column. We will also change the shift to 0 to keep it for the current bar.
Once done, you can click ok.
Note that if you are interested, you can also save these settings in order to run different parameters and test the results. The final customized Strategy Tester looks as below now.
Once everything is set up, you can now click start and let the EA run. Depending on the start and end date it will take time for the strategy tester to finish the testing. You will hear an audio notification once the strategy tester is complete. The strategy tester is now enabled again with some additional tabs.
Strategy tester graph and reports
You can firstly go to the Graph tab to see how your EA performed. In our case, the EA actually lost money. Note that we are not focusing on optimizing the EA but only demonstrating how one can use an EA on MT4.
You can also click on the Report tab to see a full summary. We will cover the various aspects of the strategy tester report in another article. The report basically tells you how profitable your EA was for the backtesting period in question.
Of importance, is the modelling quality as it will show how much data was used for the backtest.
Optimizing strategy tester – The trick up your sleeve
By the initial results, you may dismiss the effectiveness of this strategy. But before you do that, wait!

Using the optimization parameter, we can actually show improved results in the backtesting performance.
This is done by simply opening up the EA properties tab and selecting additional parameters in the optimization tab.
Once you do this and click on the optimization tab in the strategy tester, it gives you the settings to use. This will override the EA settings. The options available here are more flexible as you can limit the number of losing traders which is a critical drawback of using an EA.
Secondly, you can also use the EA’s settings to optimize for the best possible indicator and trade settings. Depending on the different combinations, the strategy tester will run through these and find the best-performing setting for you.
The drawback with this method is that while your EA is now perfectly optimized to show results for the historical period, it will in no way guarantee the same performance when forward testing.
In the chart below, we ran an optimization for the EA. Based on this, we can now backtesting using these results.
Interestingly, as the above image shows, using the different EA settings you can select different settings based on the outcome. For example, using the second set as input parameters, we can have the EA provide a profit factor of 1.98 with a drawdown of 33%.
Likewise, using the first input parameter, we can see the profit factor reduce including the drawdown, but the total number of trades is higher. Readers should be aware of this optimization which is a common trick used by many EA developers selling their wares.
The historical backtest is shown as proof of the effectiveness of the EA or the automated trading system. For personal testing purposes, you can ideally choose a smaller time period for testing and then use the different parameters to test over a longer time horizon.
This will ensure that you do not end up fitting the EA too much, while also getting an idea of how it works during the larger time frame.
To conclude, using automated testing can be a great way to automate your trading. However, you need to have a good strategy that can be automated. Thorough testing is required to see how the EA performs in different market conditions.