How to backtest EA online
In this lecture, I will show you how to backtest EA online on MetaTrader 4 or in other words, how to see the performance of the Expert Advisor. As I explained many times in previous lectures, the Expert Advisor is a trading strategy that is automated.
So in this account, I have now 13 Expert Advisors. I’ve been trading with 12 of them. And I have added one more, which I have displayed over the chart, placing the indicators. But as I have concluded, it is really hard to follow the Indicators manually. We need to spend a lot of time in front of the screen. So the best solution is to trade with Expert Advisor.
Now, when you get an Expert Advisor, no matter where you get it, whether you buy it from the market, whether you create it by yourself using strategy builders, or you code it, or you take it from our course, you have backtest EA. This way you will be able to see how this strategy performed with your broker.
Backtest EA on Different Brokers
Now, we test the Expert Advisors on a few brokers. Obviously, we can’t test them with all of the brokers. There are thousands of brokers around and that is why the best thing you can do when you have an Expert Advisor is to perform backtest EA on your broker.
And if you do actually a backtest on a few brokers, you will see how different the results are.
In our courses we have demonstrated many times that if we trade with the same Expert Advisors on different brokers, we get totally different results.
It is because the spread is different on the brokers, the commission, the swap, the prices. Usually, the brokers have different liquidity providers, which simply means that they receive different prices and usually it’s a very small difference.
But when trading with Expert Advisors, we are very accurate in executing the trades and we can see that difference.
Now, how to backtest EA on MetaTrader?
First, I will need to attach the Expert Advisor over the chart so I can double-click on it, or I can drag and drop it over the chart and I will see the small input menu.
And I don’t want to trade with the Expert Advisor right now. I just want to show you how to backtest EA online on MT4. But anyway, I will attach it over the chart.
Let’s say I will be trading with 1 complete lot and I click on OK. We see a smiley face, which means the Expert Advisor is attached over the chart.
EA Backtesting with MetaTrader Strategy Tester
You see where your trades opened and closed.
Now, what I need to do is right-click over the chart and go to Expert Advisors and select Strategy Tester.
A new window will pop up below the terminal. And there we have the setup for EA backtesting on MT4. Now, what’s very important with the Expert Advisors that are created with EA Studio is to use as Model, “Open prices only”, and usually all the rest is set automatically.
You can see I have the symbol EURUSD and I have a period of M15. It’s up to you if you want to backtest EA online on the current spread or you would like to put a little bit higher as 10, which I usually do, and then we can select the date. Let’s backtest this Expert Advisor for the last 2 years.
So we are in September 2020. I will just go back a little bit to September 2018 so I can backtest EA for 2 years. And then instead of today, I will select the 1st of September 2020. So we have exactly 2 years to backtest EA online. Now, below we have the Visual mode.
So if you keep it checked, you will see the actual online EA backtest on the MT4 chart. Let’s see how that looks. I really like it, by the way, because it gives you a visual presentation of where the trades were opened and closed. Before I click the start button, you can see there are Expert properties, from where you can change the parameters for the backtest.
We will use 1 complete lot to backtest EA
As we said, let’s make backtest EA online with 1 complete lot.
I click on OK, and I click on Start and the chart starts to move. This is since the 1st of September 2018 and the online EA backtest in MetaTrader starts after the first 100 bars, so we will see the first trades opening in a while, or if you want to see it faster, you have the Visual mode from where you can increase a little bit the speed.
What I was saying is that some strategies are more active and they open trades all the time. But that’s not always the best case because we pay more spread to the broker.
Some traders prefer to trade with active strategies. Others prefer to trade with strategies, where the trades happen rarely or we have more confirmations. This strategy is just a normal one, which has 2 entry conditions, as I showed, and 1 exit condition, Stop Loss and Take Profit. I will increase it to the maximum.
It goes fast and the EA backtest is complete. In the end, it shows the indicators that the online EA backtest uses. This is exactly the Bollinger Bands, the Escalator Oscillator. And as well we have the 2 Moving Averages, which in this case are displayed with the same color.
Now, below we have a few tabs. One is the Results where we can see all the trades that happened from September 2018 until September 2020. The final balance is at 15 203, which means it’s about 50% of a profit, or that would be $5203.99.
And if I go to the Graph, you’ll see the equity line of that strategy.
It started at 10 000 and had a couple of drawdowns and stagnations. It reached to 16 555 and it ended at about 15 200. So that’s quite a normal strategy, again I say, an Expert Advisor with profitable periods and losing periods.
And every single strategy has losing phases, losing periods, or consecutive losses.
In other words, we can say that during this time, for example, the strategy was just losing. The market conditions were not appropriate for the strategy. So it did more losses instead of profits. But overall, the strategy is profitable. In the long term, that is a profitable strategy.
And really try not to look for the strategies that have a perfect EA backtest online. These are usually the strategies that the people sell on the market and they are just over-optimized, or in other words, their parameters were fit perfectly for the EA backtest to show you great results. And usually, this kind of Expert Advisors blow the accounts of the traders.
Backtest EA Online – MetaTrader Example
Now, I will show you how to backtest EA online on the MetaTrader 4 platform. And below you can see that I have the first trade opened on EURJPY just very shortly after I placed the Expert Advisors on Meta Trader.
So here you can see the bar opened above the upper band and this time the Force Index was lower than the 0 line and it opened the short trade.
If you’re a beginner trader, it’s important to know that the Expert Advisors do it automatically.
If you are using MetaTrader 5, you can refer to our MT5 backtesting tutorial and learn the basics of backtesting.
While I was recording the previous lecture for the EA Studio and FSB, showing you how these strategies were created, the Expert Advisor opened the trade. And this is really the big benefit of using Expert Advisors. You can do anything else.
The Expert Advisors follow the market, they follow the strategies, and the indicators and the rules, and they execute the trades.
They place automatically the Stop Loss and the Take Profit. I don’t need to do anything manually once the Expert Advisors are placed on the platform. So how can you backtest the Expert Advisors?
Historical data is important when we do backtest EA online on MetaTrader
So how to perform the EA backtesting? We use the historical data which I mentioned in the previous lectures. These are all the bars that we have before that, all the candlesticks, all of that information.
And to be precise, the information is the value we have for each candlestick, the open, the high, the low, and the close, these 4 values, form the historical data. And all of that information is stored over the chart.
If I press the Home key on my keyboard, I will go back to the beginning. And as I said, when you open a new account with the new broker you will not have a lot of bars.
This is why we have now the Forex Historical Data App which I showed you on our website and you can download many bars from there. Anyway, if not, you will be able just to backtest the EA over a limited amount of historical data on MT4.
What I mean is, if I press the Home key on my keyboard, I go back to the 13th of January. This is just about 1 month and there is no more data. And how do I do the EA backtest on MT4? Right-click over the chart, I go to Expert Advisors, Strategy Tester.
Normally, it will set the symbol automatically the timeframe, just as a model, make sure to use Open prices only,
because we said that these strategies work on the opening of the bar.
A few trades are not enough to depend on a strategy
And when I click on Start, there is the graph of the results.
But this is a very small graph because it made just 27 trades. There is no historical data back in time to see how this strategy performed. And as well, when you’re doing the online EA backtest, you can set the date but if you don’t check it, you will be using the complete period.
Now, here, I don’t have historical data. One of the options to collect historical data is to press the Home key on your keyboard as I said. Let me open 1 symbol that I didn’t do it.
For example, EURJPY, Chart Window. I press the Home key and it loads the data. And if I want to do this for all timeframes, I will need to switch and hold it until it stops moving.
However, still, this has small data as I showed you with the MT4 EA backtest, not enough. So how to make an EA backtest on with more trades?
One thing is you can use our app to download historical data. The second thing is you can collect data. When you leave your Meta Trader opened, with time it will collect the data for you. But this takes normally a couple of months or even years.
Step by step guide to a backtest EA online on MT4
Now, let me show you a backtest on another platform where I have more data because I’ve been running this platform for quite a long time. So it was the EURJPY. Right over here I have some indicators. I will use a Template, No indicators, so it will be a white background.
Now, what I will do? I will show you step by step how to make the EA backtest. I need to place the Expert Advisor first. So File, Open Data Folder,
and I go to MQL4,
I will place here the Expert Advisor for EURJPY.
Close the folder then go to Expert Advisors and click on Refresh to compile this Expert Advisor,
I put it over the chart, click on OK.
Now, I don’t need to enable the AutoTrading because I don’t want to trade with this Expert Advisor.
I just want to show you how to backtest EA on MT4. Expert Advisors, Strategy Tester, and then I will select EURJPY. It is on the M15 chart, Open prices only, I will be using the complete data I have. I click on Start,
and you will see how the graph.
I have more than 2,000 trades. So that’s a realistic backtest because I have many trades, not just 10 or 20.
How to make EA backtest in MT4 visual mode?
And in results, I can see exactly all the trades that happened, where the trade was opened, where it was closed. Actually, over 2,000 orders but this is for open and close. So it’s about over 1,022 or something like that. So this is how we do the EA backtest in the MetaTrader and there is a visual mode which is very interesting as well.
You can click on it and it will show you how that behaved. How the strategy did.
It shows where the trades were opened, where they were closed. And something very interesting, you can notice how it works when the Take Profit is small, the trades open and they hit the Take Profit quite often.
When it’s open and the Take Profit is very close, it hits the Take Profit or it uses the exit condition to exit the trade. So this is how we do the EA backtest on the MT4 platform.
As I said, the historical data is very important. If I go to the EURJPY on M15 and I press the Home key, I have data since 2014 October. Very different.
So the historical data is important when it comes to how to make a backtest but as well for creating these strategies because the generator on the software, on EA Studio, on FSB Pro.
The programs use this historical data to build these strategies, and to generate these strategies, and to find the best combinations between indicators, Stop Loss, Take Profit, and all the rest which makes the strategies profitable.
You can backtest Expert Advisors online with EA Studio which is much faster
There is much similar software for EA backtesting, for generating strategies, and I’m following, of course, all of them. But for the current moment, EA Studio and FSB Pro are the top products on the market and this is why we have integrated them on our website so it’s easier for our students and our traders to use them.
You can take advantage of the 15 days trial to create your own strategies, to backtest some of the strategies, and just to get some skills in algorithmic trading which I believe are very useful.
Why do we trade many Expert Advisors?
So, one more time to summarize it, every strategy has losing periods and profitable periods, and this is why we trade many Expert Advisors simultaneously. So when one of them is in a losing phase, the others will compensate for it.
This article is based on a free lecture from the MetaTrader 4 Forex Trading course + Weekly Robots course. In the next lecture, I will talk more about trading many Expert Advisors. What are the benefits? And you will see the difference when we are trading with 1 Expert Advisor or when we are trading with many Expert Advisors, you will see how different the backtest is.
So don’t hesitate to make a backtest online for any of the Expert Advisors or to compare a few brokers and see which one will give you a better EA backtest. Because this way, you will know which broker gives more profits.
Thank you for reading the lecture. If you have found it beneficial, leave a comment below and if you want to get more of our free videos, make sure to subscribe to our YouTube channel.