Featured > Trading Articles
How To Run A Backtest
21
Nov
Running a backtest can tell us, in some circumstances, a little useful information about a strategy. The problem with backtests is that they also tell us a lot of things which can make a strategy appear a lot better (or a lot worse) than it really is. Backtests should not be used for the purposes of trying to predict your profits or make accurate calculations about how a robot will work, they are only in very rare instances accurate enough for this. As a general overall indicator of initial strategy strength however they can be interesting, and a backtest can also help you identify the strategy behind a robot e.g. what kind of stoploss and take profit values it likes to use, if it opens many trades or only very few, etc.
Here is how you conduct a very simple backtest in Metatrader:-
1. Make sure you have downloaded quote history from the Metatrader History Center. (press F2, then select 1 minute timeframe for your desired currency pair -check your robot to see which currency pairs it trades).
2. Download data a second time. When you re-download the data it will ask you “Do you want to recalculate all timeframes?” Select ‘yes’. Sometimes i have noticed that the first download of data does not yield accurate results and after going through this process any glitches are corrected. Recalculating the timeframes doesn’t take long, it is much quicker than the download itself and is well worth it.
3. Open up strategy tester. Go to view—->strategy tester to bring it up. Strategy tester appears as a box at the bottom of Metatrader.
4. In the dropdown boxes, select the expert advisor (trading robot) you are wanting to test, then the currency pair you want to test, and the “period” (timeframe of the chart the robot should run on).
5. In the “model” dropdown box you should leave “every tick” method selected. Backtests are notoriously inaccurate as they are, so by selecting a less accurate method of backtesting you are only going to amplify these inaccuracies further. The other selections in this dropdown list are perhaps only appropriate for very long term strategies (i.e. ones holding trades for many many weeks or months) and hence do not need minute by minute data.
6. Put a tick in the “use date” box and select your backtest start and end times. If you do not do this, the backtest will just run on the entire historical data Metatrader has available. Â When i first run a backtest, i like to see it run fairly quickly so i can just check everything is working and setup correctly – so i would generally start with backtesting just one to three months of data, then after a successful backtest for this period i would perhaps try running a test over the past year to three years.
7. Visual mode. Leave this UNticked if you want a fast backtest. If you don’t mind having a slower test but want to see the trades appear on your screen (helpful for analysing how a strategy works) then you can tick this box. I would also recommend moving the slider over to the right a little which speeds up the visual mode test.
8. optimisation box. DO NOT tick this. We are not optimising at this stage, just running a straight backtest (for more on optimisation, if you are a member there is an article in the members area which discusses how to optimise).
9. Now click “expert properties”. This will bring up all your settings for the robot under test. You should work your way down the settings list, setting up the parameters as you would like to test them. You only need to change the “value” column, the other three columns are not related to a simple backtest so are not needed at this stage. If your robot needs an unlock key to work, you will also need to enter it in here in the appropriate parameter.
10. Still inside “expert properties”- click on “testing”. Here you can select how much money you want to start the backtest with. You can also choose whether to take long & short positions, or just one or the other. In Forex a long position means a buy trade and a short position means a sell trade. You should also tick “genetic algorithm” which will help with backtest accuracy. When you are done click “ok”.
11. Click “start” to run the backtest. You should see a green bar progressing along the bottom of your screen if you have started successfully. A backtest can take anywhere from a few seconds to a few days (or even weeks!) to complete depending on the complexity of the EA, the efficiency of its coding, the speed of your computer, etc.
Generally, if something is going to go wrong with a backtest, it happens fairly quickly. Within 30 seconds or so you may see that it says the test is completed but no results are showing. In these instances, check the journal tab in the tester to see what errors may have been flagged up. If the test has worked properly you will see an equity curve graph and statement generated in the tester for your information and analysis.
I can’t stress enough how important it is NOT to get all excited if you see an amazing backtest. Some of the most perfect looking backtests are only so perfect looking because the seller has unknowingly (or in some cases knowingly) over-optimised and “curve fitted” the data so that it displays beautiful backtests. Â The reality going forward is often different. Often these problems are brought about by vendors altering a single parameter in their strategy in order to avoid one large loss in the backtest. They unwittingly engineer a situation whereby they have optimised for that condition so perfectly that the strategy is unable to handle similar market conditions at all – it can only handle that precise condition. This is no good to us as a trader, trading in an imprecise and ever-evolving market.
Often then, the best robots are not those with the best backtests, but the ones with fairly average backtests, which have been sympathetically and carefully optimised whilst taking into account the dangers. Of course from a sellers point of view, a great backtest sells more robots which equals more money – a bit of a sorry state to see the industry in but it happens and is going on right now.
Have fun with your backtesting! Remember to use it wisely and it can be a great addition to your knowledgebase – especially if you manage to work out how to spot those pesky over-optimised backtests when you see them sold online!
Join donnaforex today!
- Personalized Support.
Get all your questions answered personally and indepth. - Settings Support.
Get access to all our account settings plus personalised settings help. - Members Forum & Chat.
Join our friendly and focussed trading community.
What our members are saying...
Just wanted to drop a line to say that I believe you are the most honest, straight forward and cool person in the Forex world (apart from being knowledgeable about the whole deal, which is not a little thing).
You probably have quite a few people frowning at you in the "higher circles", but your members and followers surely love you for being so trustworthy and clear minded.
Sandra





3 Comments
My deepest respect for your knowledge, sharing, reactivity.Your reiews on FAPT custom levels etc impressed me. I went through the bad experiences of all type of expert guides,web trainings just to “eventually” get a BS answer (usually not more than the std definition of a setting or an ignorance).I just decided (easy) to suscribe as a member. I look forward to continue to learn from you and share some of my in depth studies on setting causalities. CU on the members site. Keep up the good work; persons loke you make all the difference; feel good about it
Max Bataille- Belgium
Donna,
Thank you for the Backtest guide very informative.
Could you please explain what is meant by the term Forward testing and the concept behind it. To me it means doing live on a demo or small account but I am not sure if this is the case?
Regards,
Simon
Donna,
Thanks for the article. One question … if this article does not address optimization then what’s the point of checking the genetic algorithm?
My understanding is that the optimization will have no effect on simple back tests when not in optimization mode.
Lastly, people need to be aware that, unless you are testing in offline mode, the spread that is used for the back test can change from test to test depending on the most recent live spread at the time the test is run.
This can sometimes rattle people when they run the same test immediately after the first run and get a totally different answer.
thanks,
Todd
Leave a Reply