Backtest Expert Advisor
Today, I would like to show you 4 different ways that you can use to backtest Expert Advisor for Forex trading. I show the 3 of them in my courses but in this lecture, I will show you the 4th one which I recently use and it works really well for me.
It doesn’t really matter which method you will be using, the results will be very similar and you will choose nearly the same Expert Advisors every time when you’re testing many EAs.
So for the beginners what’s the idea?
With EA Studio, we create many Expert Advisors and we test them to see which are the Expert Advisors that make the most profit on the current market conditions.
So the first method I will show you is called Out of Sample, and this is available in EA Studio. If you click on the Generator settings, there is Out of Sample.
The Out of Sample is a really great method because it allows us to test the Expert Advisors while we are generating them.
For example, if I want to generate strategies for EURUSD on H1 chart, I have my strategy properties of 0.1 lot, minimum 10 pips, and maximum 100 pips for the Stop Loss and the Take Profit range.
Out of Sample in the first method to Backtest Expert Advisor
Then we have the Search best where we can select how we want the software to arrange the strategies into the Collection.
Usually, I keep it to Net balance so on the top I will see the strategies with the most profit. And then we have the Out of Sample.
So if I click on it, you will see that I have 5 different options to backtest Expert Advisor – 10%, 20%, 30%, 40%, and 50%, and the 6th option is the In Sample.
So what is that? Let’s generate some strategies very quickly selecting 20% Out of Sample. The Acceptance criteria I will remove, I will remove Monte Carlo validation as well, and I will click on Start.
What I want to see are some strategies very quickly into the Collection. Here they are. I will stop the Generator. What you notice is that there is this green period for each strategy. And this is what we call Out of Sample.
So all the historical data that we have, in our case, is from the 15th of July, 2015 until the 15th of July, 2020, 5 years of historical data.
Which means that the complete period is 5 years. And I have selected 20% Out of Sample which means that the Generator uses 80% of these 5 years, of this historical data. And in the recent 20%, it backtests the strategy. Or in other words, it simulates trading.
This is really nice because it’s a real simulation, let me click on the strategy and there is the Out of Sample monitor which will show us exactly the dates. So In Sample, we have the beginning of the historical data, July 2015 until July 2019. You can see it in the picture below.
And then Out of Sample is July 2019 and July 2020. This is very easy because we have exactly 5 years of historical data, 20% out of it is 1 year. Or in other words, it means that the Generator has used the first 4 years from the historical data to generate the strategy and then it simulated trading during the last 1 year. Or it did a backtest Expert Advisor on an unknown data.
And you can see it’s a profitable strategy during the last 1 year. And below, we have more details about the In Sample part and about Out of Sample part, and then we have the complete backtest.
So this is the first method that you can use to test the strategies, or to backtest Expert Advisor, and you are simulating trading back in time.
It works really nice by the way. And you can change the period or the Out of Sample to 10% or a higher number. This is the first method that you can use, and that I use when I create strategies using the Out of Sample in EA Studio.
Data Horizon (2nd method to Backtest Expert Advisor)
Now, the second method is quite interesting because if you have noticed the In Sample, it has 10%, 20%, 30%, 40%, 50%. And if I go back to the strategy and I go to 10% Out of Sample, that would be about 6 months. I will be testing the strategy for 6 months.
What if you want to backtest Expert Advisor for just 1 month? This is possible with the Data Horizon. We have the start date on the 15th of July, 2015, and I can set Use end date limit just a month ago.
So I can put it on the 15th of June, 2020. What that means is that the Generator will use the data except for the last 1 month.
And if I go back to the Reactor, I will remove these strategies that I have generated previously. And you can see the 15th of July, 2015 until the 12th of June, 2020.
Probably the 13th and the 14th of June are over the weekend. This is why I have set the 15th but it starts from 12th.
Not probably, I’m sure this is the reason. So I have removed from the historical data the recent 1 month. Now, let me again generate strategies quickly so I can show you what exactly I’m doing. And I already have some strategies into the Collection.
I remove the recent 1 month from the historical data
I will wait to see at least 15 to 20 strategies. It works a little bit slower now because I have the other 3 Reactors working simultaneously. 20 strategies. I will stop now. Now I will go to Data, Data Horizon, and, one more time, I have removed the recent 1 month from the historical data.
What I will do now, I will change the Data Horizon to the recent 1 month so it will be 15th of June, 2020 until today which is already 16th of July, 2020. And this means that I have only the recent 1 month now as Data Horizon. And I will go back to the Collection and I will click on Recalculate. That method of backtesting Expert Advisor simulates Demo or Live trading.
This way, I will see how these 20 strategies performed during this last 1 month. I have some correlations to be resolved and here it is. And don’t really look at the results because I have run the Generator just for less than a minute.
But, for example, looking at the first 2 strategies, what I have here is the first strategy had 2 trades for this month and they were on profit.
If I click on Report and I go to Journal, I have 2 short trades and both had $61.80 as a profit. What about the second strategy?
Better to have a few positive trades
It had 9 trades during the month.
And then if I go to the Report, I can see exactly what were the trades. Some decent trades over here. So this is how you can backtest Expert Advisors for Forex trading with EA Studio using the historical data, and it’s a really quick method to do that.
Just remove the recent 1 month, and then recalculate the strategies for this 1 month.
The 3rd Method to Backtest Expert Advisor
The third method is the most common one and this is what I show in most of my courses. Let me go back to Data Horizon, I will bring it back to the way it was, 15th of July, 2015.
I will not use the end date limit. I go back to the Collection, I recalculate the strategies that I generated quickly, and here they are. Now, what is the third method to backtest Expert Advisor? What is the most common way to test Expert Advisors is to place them on Meta Trader with EA Studio.
It’s very quick because, with one click, you download the strategies. So when you have many Expert Advisors, you can put them on Meta Trader and leave them trading for 1 month on a virtual account. And then with the Magic numbers, we see which are the top performers following the results in FX Blue, MyFXBook, what I show in my other courses.
Have 2 Meta Trader platforms installed on your computer
And this is really a great method to test many Expert Advisors by placing them on Meta Trader. But as you know, each Expert Advisor works on a separate chart. So sometimes it’s a little bit of work. For example, if you are trading with 99 Robots like what I demonstrate in my Automated Forex trading course, we need to have 99 different charts opened and then we need to place 99 Experts.
It takes some time. For some people, it’s a lot of work. For me, it’s not because I’m used to it and it happens quite quickly. But for this method, you need to leave your Meta Trader open all the time. And something very important, if you are testing Expert Advisors on a Demo account to see which are the top performers to place on a live account, make sure you have 2 Meta Trader platforms installed on your computer.
Don’t switch between Demo and live account because if you are in Demo, you put many Expert Advisors, they start trading, and then you switch to a live account in the same platform, you will disable the Demo account and the other way around.
If you are in a live account and you switch it to Demo, you will disable the live account. So if you have live and Demo account, you need to have 2 different platforms. So this is the third method, the one that I show in most of my courses.
Backtesting Expert Advisors might be a lot of work
But, one more time, it takes a little bit more work to place each Expert Advisor on a separate chart. And if you are testing hundreds of Expert Advisors, it is a lot of work and this is what I do. But this is my job so I don’t complain about it.
The fourth method which saves me a lot of time, and this is what I will show you in this course, is to generate the strategies and then I download just the Collection. From there,
I wait for 1 month. For 1 month I don’t do anything.
I just wait, prepare my next strategies, I record courses, I travel a lot recently, basically, nothing to do with this Collection. So usually, with this method, I do not backtest Expert Advisor in the past but I wait 1 month for the new unknown data. I gust generate strategies for different assets.
And then I will download the Collection and I will do nothing for 1 month. Why? After 1 month, I will add the data for the last month, I will download it from the Forex Historical Data App, and then I will recalculate the strategies in the Collection.
This is a real future testing for the strategies. I don’t know what will be the data in the next 1 month. Nobody knows that. But I’m generating the strategies now and I will save them as Collection, this is the easiest way to go. After 1 month, I will add this new data in EA Studio and I will recalculate the strategies.
It is easy to do all of that with EA Studio:
Test the different ways to backtest Expert Advisor and see which one wirks for you.
And I will see which strategies performed the best during this 1 month and those strategies, I will be trading. This is really a time-saving method and I’m using it more recently and I will demonstrate it to you in the 30 Best Strategies course.
In the course, I will show you the whole process and how exactly I’m trading with the strategies, and how easy is to backtest Expert Advisor.
Thank you for reading the article and if you have any questions, post them below in the comments or in our trading Forum.