Backtesting Forex Expert Advisors – the only way to test a strategy
Backtesting Forex strategies is a key point in Algo trading. Hello, dear traders, in this lecture I will show you how to do backtesting Forex strategies when you place them on the Meta Trader. Now, what backtest Forex means is that you can actually see the results for this Expert Advisor for this strategy, over the past. And this is possible with Meta Trader because we see the charts back in time.
This lectures is free and it is part of the complete Meta Trader course called MetaTrader 4 Forex platform: Start trading with a pro trader
What I showed you with the other platform right here, trading the strategy manually, is because I wanted to show you how these strategies work:
- where exactly is the entry,
- where exactly is the exit,
- the Stop Loss,
- the Take Profit etc.
Historical data and Backtesting Forex EAs
But imagine here if I press the HOME key on my keyboard, I will go back to the beginning. This means the maximum chart I see back in time.
And if I take the cross here, this is 9th of January, 2018, so imagine I go 1 year back to follow every signal and every confirmation, it will take me a long time and I cannot do it so precisely. So what we can do with Meta Trader is actually to perform a backtest.
What do we see when Backtesting Forex EAs:
- entries for the trades
- exits for the trades
- the exact time the orders were executed
- trades that we were having with the strategy, for all of the historical data.
We say this is historical data. The chart back in time.
If you don’t see much historical data you should press the HOME key on your keyboard and hold it. Because I have already done that, it’s not moving. But normally if you have just installed a Meta Trader and you press HOME key it will move quickly. Just like this, and it will load you as maximum as possible.
Have much data while conducting a backtest.
So when we do backtesting Forex EAs, it’s good to have as much data as possible. And what you need to do in order to perform the backtest, is just right click and then go to Expert Advisors and then go to strategy tester or you can press F6 as well. You see a small window comes up where we have the symbol and we have the Expert Advisor. We don’t need to change anything right here:
And then you have model, open prices only, you have three options normally with Meta Trader:
- every tick,
- control points
- open prices only.
This is how we create our strategies to open the trades on the open of the bar as I have explained why.
That is why here, as a model, you need to select open prices only. This is if you want to select a date, from which to which date to test the strategy. Or if you untick it, you will be using the whole data. The whole historical charts that you have with your broker that is. And then here you have visual mode so I will first remove it and then I will show you what the difference is if we use it.
And then on the right side, you have the period, so it’s on H1 and then you have the spread. You can enter any spread or you can leave it to current. Now, one of the other reasons that I have decided to show you on this platform is because here, my spread is a little bit bigger with this broker.
Why I perform backtesting Forex test with Expert Advisors on different brokers.
If I go to spread, you will see that it’s just a little bit above one pip for the major currencies, which for me is high spread. But for all the Expert Advisors for all my courses, I always test the Expert Advisors on a few different brokers to make sure that they’re working properly for different brokers. Because obviously, you, as a trader, will take it and you will place this Expert Advisor on some other broker, so I always make sure that it works on a couple of different brokers well.
And of course, I cannot test it on all brokers because as we said at the beginning of the course there are thousands of brokers but I always test it on few brokers to make sure they work properly. So here as a spread I normally leave it to current spread. If I press on start you will see very quickly the backtesting Forex test is done.
And I go to results and here you can see all the trades that were opened and closed, the profit, the losses that we have, the balance on the right side, what it was was it a sell, what happened after that Take Profit was hit, then another sell Stop Loss was hit, then another sell Take Profit was hit and so on. If you go to the graph, you will see the equity line of this Expert Advisor. So here you can see that we have so far very good equity line for this Expert Advisor.
Use a Demo account first.
Of course, as I’ve mentioned it is never a guarantee that the performance will continue. That’s why the best thing to do is to test these Expert Advisors on Demo account. And if you like their performance you can try them on the live account. But one more time this is your own risk that you’re taking, your own responsibility.
The purpose of the course is just educational
I provide these Expert Advisors for you, guys, just to give it a try, to practice trading with Expert Advisors and see if you will like it. Then with the Backtesting Forex report, we have some more statistics as profit factor, which is the ratio between the net profit and the net loss. And then we have the absolute drawdown, total trades. So you see there was an execution of 581 trades with the backtest, which is a pretty good number I can say to depend on this strategy.
So, there was the execution of 581 trades during the backtest. We can say this is a robust strategy because if we were having only 10, 20, 50 trades, it would be a very small number to depend on this strategy. And there are other statistics here that I’m not going to read all of them. Then in the journal, there are some more details about each open trade.
Backtesting Forex strategies with a visual mode.
So now, I said that I will do a backtest with a visual mode so we can see the difference. And here we have a scale from which we can change the speed. So let’s leave it to the middle and I will press start which means it will perform another backtest.
As you can see, it shows us the backtesting Forex test very slowly where the trade was opened. For example, here we have a buy order. Where was the Stop Loss, here was the Take Profit hit, another order etc. And if I just move it a little bit to the right it will go a little bit faster.
So here you can see how it is moving. How the chart is moving, what happened in history, where the trades were opened, where was the Stop Loss, the Take Profit. Just the Take Profit was hit and another trade was opened. And normally, when we use the visual mode it opens another chart. So it’s not over the EURGBP where I have started the backtest.
It opens another visual chart and if I just make it to the right to the maximum you will see how quick it is and it does the backtesting Forex strategy test. It shows you the indicators but as we said, if we are trading with the Expert Advisors, we don’t need to place the indicators over the chart. Just at the end of the visual backtest it shows us the indicators.
The visual mode gives an idea of how active the strategy is.
And here again, if I go to the results, to the graph you will see the graph. So the visual mode gives us an idea, how active is the strategy, how many trades were opened, and you see if I just go back there are small arrows. When we have a long trade we see a green arrow, and then where it was closed.
And then we have a short trade with a red arrow, and then here the Stop Loss was hit. So here when we have a Stop Loss hit or a negative trade, we see this red line and when we have this profitable trade, like here, we see a blue line. I don’t know if it is really visual but you can see there is one blue line, as well here there is a blue line and so on.
And then here, there’s another red line, so here the trade was open for quite a long time and then other trades are here. The visual mode gives us a better idea about the strategy, you can play around with it it’s very interesting. I will close it and I will do a backtesting Forex test for the others as well.
So this was for EURGBP, I will do it for EURUSD as well. I will go to Expert Advisor, strategy tester…so you can see when I go from the chart where the Expert Advisor is, we have everything set here; the chart, time frame, the Expert Advisor, nothing really to do. Let me slow it down a little bit so you can see how this strategy will work. I will just start moving it a little bit to the right.
Backtesting the Forex strategies is fast because the coding of the Expert Advisors is well done.
Here it is, you can see the trades are opening, closing, opening, closing and let’s make it really quick. You can see it performs the backtest very quick because the coding of the Expert Advisors is very good. There is nothing unnecessary in the code which makes the backtest very quick.
And in the results and the graph you can see the graph of this strategy for EURUSD and here is the report and here is the journal. And I will make a backtest as well for a GBPUSD. Right-mouse, expert advisors, strategy tester and I will make it a little bit to the left first.
I press on start and you will see how the price is moving. This Expert Advisor, if you remember the strategy, it has a signal and then it has two other indicators which are confirming the trade. That’s why you see there are not so many trades like the other Expert Advisors, but only when the other indicators confirm the new trade.
Make a backtesting Forex on your broker as every broker has a different historical data.
Let’s make it quick and we will see the results. Here, the indicators that were used are displayed and I go to results, then to graph and you see another very stable graph that I have. So to make it one more time clear, when I am building these strategies, these Expert Advisors, I am using the historical data of one broker.
Then I do backtest on a couple of more brokers. I do this to make sure that the performance of the Expert Advisors remains profitable. So it is good to make a backtest on your broker when you place it because every broker has different historical data. This is very important.
The different brokers provide different bid and ask price, they provide different spread which forms different candlesticks. It could be a very small difference, guys, but with algorithmic trading, it is not a small difference. That is why it is good to make such a backtest to see the performance of your broker.
Expert Advisors from the market are very expensive.
But one more time, the course is for educational purposes. I provided these three Expert Advisors so you can actually get free Expert Advisors. Because, if you want to buy Expert Advisors from the market they are very expensive. Also, basically, you don’t know what you are buying. Backtesting Forex EAs does not guarantee future profitable trading.
So here, I have explained what exactly the strategy is, where exactly the trade is opened, where exactly it is closed and as well I have shown you how to place them over the chart and how to perform a backtest. One more time the backtest is not a guarantee that this strategy will continue trading profitably in the future. And that is why I am trading with many Expert Advisors over different currency pairs, different assets, cryptocurrencies, commodities, stocks but mostly I am trading Forex.
I am testing hundreds of Expert Advisors on Demo account. I am doing a lot of backtesting Forex tests and I choose which ones to use on my live accounts. And if any starts to lose, I just replace it with another one. One that I have already created, backtested and tested on all Demo account. Alright?
So thank you very much for reading the article. Don’t hesitate to ask me any questions in our trading Forum if you have, about the backtest of Expert Advisors.
This article is free and it is part of the course MetaTrader 4 Forex platform: Start trading with a pro trader