MQL4 TUTORIAL BASICS – 3 HOW TO USE THE STRATEGY TESTER

video

In this video we want to find out how to use the Strategy Tester.
This is an Expert Advisor, an automated program for Metatrader 4 and its running with historical data that is called a strategy test or a back test, and we want to find out how to use the Strategy Tester.
Last time we have created this simple template here, it just creates an output: “Hello MQL4”, so let’s click on; “View/ Strategy Tester” or press CTRL and R.
Now you should see this “Strategy Tester” panel here, here we can pick an Expert Advisor, in our case the “SimpleEATemplate”, we also pick a “Symbol”. A Symbol is a currency pair in our case but you need to have historical data for the currency pair you choose otherwise the strategy test will not start, so let’s click on: “Tools/ History Center” or press F2 and here we see we have data for 1 minute charts for the currency pair that we have chosen, but when you scroll down here you will see that we have some data for 2017, and we have data for 2013 but we couldn’t start a strategy test for 2014 because the data is missing.
There are some websites where you can download data, like: histdata.com, they offer 1 minute data for Metatrader 4, just pick the currency pair you need, select the year, in our case it’s 2014 and click on the download link and once the data has downloaded you will see that it contains a coma separated file, let’s open it and here we are!
This file contains all the data for each minute of 2014 – I have already downloaded a lot of those files – but in our case we just pick the year 2019, I have selected the 1 minute chart, the spread is set to 10, we will trade every tick and to see what’s happening just set the mark here to enable the visual mode and start your test.
Ooh… I need to change the year, let’s start the test again and this time it runs.
Not very spectacular, we just see the text: “Hello MQL4”, so let’s exchange that with the output: “Local Time: “, there is a function for that which is called: “TimeLocal”, let’s recompile the code, start the test again and this time we have a rising counter here that is calculated with each price change on the chart and in this video you have learned how to use the Strategy Tester, how to use the function: “TimeLocal” to create a dynamic output directly on your chart and you have coded it yourself with a few lines of MQL4 code.