Backtesting with Metatrader’s Strategy Tester

So you’ve just gotten your hands on a hot new expert advisor and you need to know if this thing is really going to work. It’s time to get your hands dirty and start testing. There are two types of testing you should do: forward testing and backtesting.

 

But first, make sure you have high quality minute data for your backtest. Read our previous article on Downloading and Setting up History Data to Get 90% Backtesting Quality.

 

Forward Testing:
Forward testing simply means to open a demo account and run the expert advisor in real time to see how it works and performs. Forward testing is essential, however it takes a lot of time before you get a good idea about how the expert advisor will perform. Instead of relying solely on forward testing, we can also perform backtests.

 

Backtesting:
Backtesting lets you test years of data in just minutes. So, before we decide to spend a lot of time forward testing, we can use Metatrader’s Strategy Tester to see how it will perform long term.

 

Strategy Tester also allows you to optimize your expert advisor. See our optimization article on this.

 

History Data

 

Before you start backtesting you will need to make sure you have complete and accurate history data set up. If your modeling quality is less than 90% or you see mismatched chart errors, then your data is insufficient.

 

To download history data and learn how to set it up, read our previous article: How To Set Up Metatrader History Data And Get 90% Backtesting Quality

 
 

Strategy Tester Backtest Settings

 

Now that you have your history data set up, let’s start backtesing!

 

To open the Metatrader backtesting window, select from the top menu: VIEW > STRATEGY TESTER (or Ctrl + R for the shortcut). The window should open in the bottom of the terminal and look something like this:

 

 
 

Most of the Strategy Tester input values are pretty self explanatory. First, select your Expert Advisor and the Symbol of the currency pair you want to test.

 

For Model enter Every Tick (the most precise method based on all available least timeframes to generate each tick). This mode allows to model price movement within a bar the most precisely.

 

For Period enter the time frame you want.

 

Leave Optimization unchecked for the moment.

 

Check Use Date and select the start time and end time that you want to test. Make sure you have quality history data for this time period.

 

Select Visual Mode only if you want a visually step through the backtesting. Go ahead and try this to see how it works. It is a good tool for checking the logic of your expert advisor and to spot any errors. However, it does take a little more time to perform, so you might not want to always use this.

 
 

Next, click on the Expert properties button on the right.

 

Select the TESTING tab. Enter an Initial Deposit value and leave everything else the same.

 

Select the INPUTS tab. This is where you enter any input values for your expert advisor. These will vary depending on your own EA. Change what you want, or leave the default settings.

 

Don’t worry about the OPTIMIZATION tab for now. Click OK to close the box.

 

Now you are ready to start your back test. Hit the START button and let’s see what results we get. Depending on your EA and computer memory, it may take several minutes to hours to complete.

 

Once your backtest has completed, it is time to Analyzing the backtest results >

 



Tags: ,




2 Responses to “Backtesting with Metatrader’s Strategy Tester”

  1. Gabriele says:

    Hi

    I tried many backtest using the Simple MACD but I have a question…

    Using the Tester In Expert properties there are some Inputs of Variable

    Value Start Step and Stop

    How this values change the behaviour of Expert Advisor?

    When I drag and drop the Expert the program don’t ask this 4 Veriables but only 1…. VALUE

    Is there a possibility to put inside the code these 4 variables?

    If not how disable using backtest?

    Thank you in advance

  2. admin says:

    Gabriele,

    Thank you for your question. The Input values START, STEP, & STOP are used for optimizing an expert advisor.

    So, for each input variable, you can backtest and find the input variable value that works the best for the given time period you backtest.

    Start Value – The value you start the variable at.

    Stop Value – How High you want the variable to be tested to.

    Step Value – The increment you want the backtester to move through the Start/Stop range you select.

    So, for the TakeProfit variable, you might start it at 50, step at 25, and stop at 200. This would run through the options: 50, 75, 100, 125, 150, 175, and 200 to see which worked best.

    These values are only for backtest optimization and are not used when you run the expert advisor live.

    I hope this answered your question. I will be writing an article on optimization soon, so stay tuned. Thanks!