Download the historical data for the desired symbol in a proper MT4 bar format. Below you can see an example of the historical data compatible with MT4. One line represents one candle (interval) for the specified timeframe. The columns separated by a comma (other delimiters: “;” “tab” “space” are compatible too) are defined as follows:
Date, Time, Open, High, Low, Close, Volume
2020.11.22,22:00,1.18538,1.18547,1.18537,1.18541,12 2020.11.22,22:01,1.18540,1.18542,1.18537,1.18541,28 2020.11.22,22:02,1.18547,1.18547,1.18537,1.18541,32 2020.11.22,22:03,1.18541,1.18541,1.18538,1.18538,16 2020.11.22,22:04,1.18541,1.18541,1.18541,1.18541,8
Open the MT4 Terminal and log into your account. If you do not have the MT4 terminal and demo account installed yet, you can proceed by creating a new one at one of my Trusted Brokers.
Press F2 to open History Center or you can use menu by clicking on the Tools/History Center.
When successful, the History Center window will pop up. You can find there all your broker’s supported symbols and all the historical data available at the moment. You can also Add/Edit/Delete individual candles, but I would not surely recommend it because that may completely destroy the validity of the data. You can Import and also Export once imported data.
To Import your historical data, several crucial steps need to be done. Otherwise, you will not end up with valid data for testing.
Find the symbol you would like the historical data to be imported for. You can easily expand the data structure on the left part of the History Center. When you find your desired Symbol/Timeframe, you need to double click it to expand the historical data on the right side of the window. Check the left upper corner if the Symbol and Timeframe matches.
Delete any data that are currently in the History Center. That way, you will prevent any inconsistencies that may occur because of two incompatible datasets. You can delete the data two ways:
1. Select (click on) the first record, scroll to the last record (using the scroll bar), and when holding shift, select the last record. That way, all the records should be highlighted in blue, and by pressing the Delete key, all selected data will be erased.
2. You can also delete the data in the MT4 Terminal Data Folder. When doing so, the MT4 Terminal must be closed. You can find the historical data file in File/OpenDataFolder/history/YourServer/DATA.hst. The name of the DATA file will always be in the following format:
Symbol + Timeframe (in minutes) + .hst => “EURUSD” + “1” + “.hst” => EURUSD1.hst
When all the data is cleared, you can import your historical data to the History Center. Check again that you are working with a proper Symbol and Timeframe and select Import.
There are multiple options on how to specify the details when importing the data, but I will pinpoint the most crucial ones so that you can be sure everything is done correctly.
- Set a proper path to your file. You can find it by clicking on the Browse… button and searching for the historical data on your computer.
- The data should appear, as shown in the picture above. If not, check if the separator in your data file matches the selected one. It may take some time to gather all the data from the file, so be patient.
- Do not skip any columns or rows.
- I would not recommend using the MT4 hourly Shift at any point. I got used to always work with UTC in the first place. You will rarely need any shifting or conversions when working with UTC.
- Import all the data you have available in your file.
- I would not recommend ticking the Volume column. When testing, the MT4 generates “random” ticks based on the OHLC prices and Volume. The tester will have to generate the same amount of ticks (price changes) as the value of Volume. So when you import the data with a high Volume value, it will naturally slow down the testing. On the other hand, when the Volume is not ticked, MT4 will automatically assign the lowest possible Volume – the number of ticks to cover the whole candle (interval) during the test. Always double-check that the previously uploaded symbol does not skew the value of Volume.
When everything is done, hit OK the data should be imported to your MT4. To keep all the data after you close the Terminal (some part of the data may be currently cached), you need to enable the MT4 Terminal to keep as much data in history as possible.
Go to Tools/Options (Ctrl+O) and select Charts bookmark. To keep as much data in the Terminal as possible, set the maximal number to the “Max bars in history” column. You can do it by simply filling in as many “9” as you can, and the number will be automatically set to the maximum.
This way, you will be able to access the historical data anytime you will be testing, even after you close your MT4 Terminal. There is also a “Max bars in chart” column, which I personally do not set too high because the MT4 Terminal will be visualizing all the available data (when the chart is open), and all the indicators will also be calculated. This takes a lot of computer resources, especially the memory allocation, and will slow down all the Terminal operations.
You can set the “Max bars in chart” to the maximum when you need to manually examine past historical data (when checking after initial import) or whenever it needs to be visualized. When backtesting and especially live trading, lower the value back again to a reasonable level.
Check the imported data by opening the particular Symbol and Timeframe, disable automatic chart scroll, and press the Home key. This will move the chart to the oldest data available, and you can go through it and check if it was uploaded successfully. At the end of the imported data, you may see a gap resulting from a difference in the uploaded data and newly incoming market data from your broker. It is necessary to know the time range of the uploaded data and work exclusively within that range. This is the only way how to be sure the historical data is consistent.
This was the most basic way to import the data to MT4 from a CSV file. A few other methods for getting the data into MT4 will be covered in another post focused on historical data. I hope this guide helped you with understanding how to work with the historical data. If you have any feedback, questions, or problems regarding the import, feel free to share them in the comments.
Still, have no trading account yet? Open an account at one of my trusted brokers suitable for algorithmic trading completely for free and start testing today!
This post contains affiliate links. If you use these links to register at one of the trusted brokers, I may earn a commission. This helps me to create more free content for you. Thanks!