How to Make a Backtest on MetaTrader


Meta Trader is the most popular platform for Algo Trading with EAs

Hello, dear traders, I will show you in this lecture how to make a backtest on the Meta Trader 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.

how to make a backtest
First trade opened on EURJPY

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.

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?

One is with the software I showed you, the EA Studio, and the FSB Pro, you can see a very detailed test. But let me explain to you in a few words what is the backtest.

Historical datais important when we do backtest on MetaTrader

How to make a backtest? We use the historical data which I mentioned in the previous lecture. 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, they 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 over small historical data.

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 backtest? Right-click over the chart, I go to Expert Advisors, Strategy Tester.

how to make a backtest with a few clicks
Right-click over the chart, go to Expert Advisors, then Strategy Tester

Normally, it will set the symbol automatically the timeframe, just as a model, make sure to use Open prices only,

Use Open prices only as a model

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.

The graph

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 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 backtest, not enough. So how to make a backtest 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

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 Template, No indicators, so it will be a white background.

I will remove the indicators

Now, what I will do? I will show you step by step how to make the backtest. I need to place the Expert Advisor first. So File, Open Data Folder,

How to make a backtest step by step
Go to File, then Open Data Folder

and I go to MQL4,

Go to MQL4

Experts.

Select Experts

I will place here the Expert Advisor for EURJPY.

how to place Expert Advisor on MetaTrader
I will place the EURJPY Expert Advisor

Close the folder then go to Expert Advisors and click on Refresh to compile this Expert Advisor,

how to make a backtest with EAs
Go to Expert Advisors then click on Refresh

I put it over the chart, click on OK.

How to make a backtest
Drag it over the chart and 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 make a backtest. 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,

Click on Start

and you will see how the graph.

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 a backtest in a 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 backtest in the Meta Trader and there is a visual mode which is very interesting as well.

how to make a backtest in visual mode
Visual mode

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 backtest on the Meta Trader 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 learn how to make a backtest on EA Studio which is much faster with the free trial.

There are much similar software for 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.

Thank you for reading!