MQL4 TUTORIAL – FIND REMOVE AND FIX CORRUPTED BACKTESTING DATA

In this video, I wanted to talk about back-testing.
This is an automated trading system. Its trading the year 2016 right now, lets speed it up a little bit and you can see that we are making progress here. We also would like to back-test the whole year 2017, so you see that the Expert Advisor is running, lets stop the test here and we change the year to 2017 and start another test.
It does work somehow and now it’s finished but the first trade started in November 2017!
In this case we made a loss of nearly 300 Dollars; here is the complete report; just a single trade and a big loss, something is wrong here, but what?
Let’s slow down the speed here and stat a new test, and now you see that we have a strange change from December to November here.
Now what is the cause?
Actually Metatrader 4 is going to use historical data. When you click on “Tools/ History Center” or press the F2 key you will see that we have data for each and every minute here, now let’s get down here and here is the problem! This is November 2017 and right below we have December 2016! So, obviously we have corrupted historical data here and now we want to fix that.
The best way is to mark the first position in the “History Center”, please make sure that you have selected the 1 minute bars, now scroll down all the way, hit the shift key and mark the last entry. Now we have selected all the records and we click on the delete button. This takes a few seconds, we have still two entries here; but these are current entries from today. Let’s change to the 5 minutes data, do the same again, delete this data for 5 minutes and now I am going to do it for each time frame in the “History Center” because I want to avoid gaps that might occur just from corrupted data that might be in any of the other time frames. Sometimes you have to wait a little while or you need to start over. Mark it again, but the higher the time frame the less data you have to mark and delete.
Eventually we have reached the monthly data and now we are done. There are a few websites where you can download historical data; I like the histdata.com website because it’s easy and free. Here you will find a “zip” file with the complete year 2017, these are 1 minute bar quotes, so let’s download that file, it’s about 3 Mega Bites and when you open it you will find the “csv” file that contains all the necessary data for the whole year, let’s copy that.
This is my folder for history data and in the “History Center” I select 1 minute, click on “import” and now I select the file we have downloaded, click on “open” and here is all the data we need, but please make sure that you don’t mark “Use selected only” because that would prevent you from importing all the data. So, let’s click on “OK”, now we see the complete year 2017 in the “History Center”, so we can close it.
When we stop and restart our back-test it now starts in January. We have already several results here, so now you know how to find corrupted history data, where you can download new data, you know how to import it into the “History Center”.