In this lecture, I will demonstrate to you how you can export and download the EURUSD historical data of your broker. Moreover, as a resource file for this lecture, you will find a script that will help you with the download.
EURUSD historical data – medium
Let’s start by opening EA Studio and going to the Generator tab. On the Generator, you will see that the first box says Historical data, and I have Data source below.
MetaTrader-Demo is the data source that comes by default from Expert Advisor Studio and if I just click on it, I see many other sources of historical data from different brokers.
So what you need to do in order to import your historical data in the software is to go back to your MetaTrader platform and place the script.
Placing the download script in MetaTrader
So how can you do that? Go to File, and then Open Data Folder,
after that click on MQL4 folder
and then go to Scripts folder. You need to paste the EURUSD historical data download script in this folder.
Here it is, EA Studio Data Export MT4. And, of course, if you’re using MT5, you need to paste the script for MT5. You will find attached both scripts to this lecture.
After that, close the folder, go to Scripts in MetaTrader, and click on Refresh. This will force MetaTrader to compile this script and you will see it displayed.
How to load the EURUSD historical data
And before I use the script, I will show you how you can take the maximum bars of your MetaTrader. If you install the platform for the first time, what you need to do is to press the Home key on your keyboard and hold it. Now, because I have done that already it’s not moving but if you install your MetaTrader for the first time and you press the Home key on your keyboard and you hold it, you will see that the chart is moving.
Basically, it will move very quickly and it will load more historical data. So do this for the asset you want to trade. If you want to trade EURUSD, just go to M1 first, press the Home key and hold it, after it stops moving, go to M5, and do this for all timeframes. You need to do this just one time in the beginning.
After that, with time you will collect more historical bars when the new data comes. Keep in mind that most of the brokers don’t provide a lot of historical data at the beginning which is very normal so the best way is to collect it with time. I don’t suggest you download the EURUSD historical data from your history center. So if you click on Tools you will see History Center.
But if you download EURUSD historical data from here, you will see that this data is not actually from your broker.
When you install MetaTrader for the first time
So, for example, if I want to download the EURUSD historical data from the History Center and I double-click on it and I double-click on M1, it loads and I click on Download. You will see the message that pops up, “You are going to download data from the MetaQuotes Software Corp. history center but your account is opened on the JFD.” This is the broker I selected to use.
So they are warning you that you are not downloading the data you need. You are downloading the data EURUSD historical from the MetaQuotes Software Company which is actually the company that developed the MetaTrader platform.
What you want to do actually is to create the strategies over your historical data. Or if you are doing a backtest of any of the strategies, it is again a good idea to do it over the historical data of your broker.
And one last thing about the data. If you install your MetaTrader for the first time you will hit the 65K limitation. So if I go to Tools and I click on Options, you will see in Charts that there is a 65K limitation and normally this is how you will find your MetaTrader for the first time when you install it. What you need to do, press 9 and hold it and then do this for Maximum bars in the chart as well, and then click on OK and you will remove this limitation.
Maximum count of bars
Press the Home key again, hold it, and it will load more bars, more than 65K. After that, go to the EA Studio Data Export MT4 script and drag it over the chart. You will see a small menu that will ask you for the maximum count of bars you want to export. Normally, I leave it to 200,000 but if you do it for the first time, 100,000 would be alright because you will not have a lot of bars at the beginning.
And then you have the spread. You can enter the current spread. At the current moment, it’s a little bit higher for EURUSD but this is because I am writing this lecture just after midnight and after that, it will go back to normal. And if you want to enter a value, it’s good. But normally, I leave it to 0 which will round it to the higher number.
So if I leave it to 0 and, for example, my spread with EURUSD is normally 3, 4, 5, this means it will round it to 10. And if you have higher spread like 23, 24, 25 for any currency pair, it will round it to 30. So I leave it to 0 and here is the Commission in currency. For this broker, I have $6 of commission for each lot traded.
The JSON files
So I will leave it to 6 and I click on OK, and you will see what will happen.
On the left upper corner, I will see all of the EURUSD historical data exported.
I have 200,000 bars for EURUSD on the M1 chart, the same for M5, and then for the rest, the number decreases. And EURUSD 1,440 is the daily chart. I have 1,576 days or bars. And after that, I need to go to File, Open Data Folder, and I go to MQL4, and then I go to Files.
This is the data I am looking for, these are the JSON Files that were just created.
And then I will open Expert Advisor Studio. I go to Data, and here is the drop zone. This is where you need to drop the EURUSD historical data files or you can just click to upload them. I normally drop them, so I just take them and drop them in the box.
All the EURUSD historical data is imported and uploaded in EA Studio.
So if I go to the Generator and I click on the data source, I will see the historical data, JFD Demo, EURUSD on M15.
It is from the 21st of February, 2018 till the current moment. And actually, this is the timezone of the broker. For me, it’s just 15 minutes after midnight but you can see the broker uses GMT time. It is a little bit after quarter past 10 PM.
I have the EURUSD historical data and I am ready to use it and generate trading strategies with Expert Advisor Studio.