Want create site? Find Free WordPress Themes and plugins.

This page is obsolete and no longer maintained. Please head to the support page and browse the support articles for information regarding Tick Data Suite v2.

If you’re reading this guide, I will assume you already downloaded your tick data either from one of the free sources mentioned on the Downloading free tick data page or from your own private source and now you need to use it in Metatrader 4.

Note: please refer to the old version of the guide if you’re using MT4 build 509 or older.

Converting the data

To put it simply, Metatrader 4 does not know how to directly read a CSV file containing tick data and thus it cannot use it in your backtests. However, what it can read is a proprietary file format that contains ticks so all we have to do is convert from our CSV file to FXT, the latter being the format I mentioned. To this end, I wrote a few scripts but later decided to make it less complicated and merged them into a single script that should be able to convert data from pretty much any source and put it into an FXT. One thing to note is that during backtesting, Metatrader 4 also makes use of the HST files when calculating the indicators so in order to have accurate tick data backtesting, you must also have HST files that match your FXT file.

So, what you need to convert is the CSV2FXT binaries that can be found in the tick data downloads section. It’s important to note that for the newer MT4 builds you will need CSV2FXT v0.44 or higher. Metaquotes changed the FXT and HST format after build 509 so all builds newer than that require the modified script. It’s a good idea to get the latest script even if you already have a compatible version.

Here’s a short guide on how to convert the tick data to an FXT file and a series of HST files:

  1. If you haven’t done so already, you have to head to the tick data downloads section and download the CSV2FXT binaries archive.
  2. Copy the files from the zip archive to your MT4 data folder. To find out what is your data folder, open MT4, head to File and click Open Data Folder, which will open an explorer window with your MT4 data folder (typically looks like C:\Users\[username]\AppData\Roaming\MetaQuotes\Terminal\[32_character_hex_string]\). There’s a directory structure inside, make sure the files land in the proper places (CSV2FXT.mq4 and CSV2FXT.ex4 must be in MQL4\Scripts, FXTHeader.mqh must be in MQL4\include, CsvReader.dll must be in MQL4\Libraries). Note that if you are using the /portable switch, your data folder will be the same as the MT4 installation folder.
  3. Move the tick data file (the CSV file) to MQL4\Files in the same MT4 data folder.
  4. Open a chart for the pair that you have data for (if you have an EURUSD.csv file, you MUST open an EURUSD chart).
  5. Select the timeframe that you wish to generate the FXT for. For instance, if you want to backtest on M1, then select M1 as the chart timeframe. Please note that the FXT file that you create for a particular timeframe (even M1) will NOT work for any other timeframe; you simply have to generate a new FXT if you want to backtest on another timeframe.
  6. Ensure that your terminal is connected to the broker (look in the lower right corner, if it says “not connected” you need to fix that before proceeding).
  7. Make sure that DLL calls are allowed. If you don’t know how to do that, you have to open the Tools menu, select Options, select Expert Advisors and ensure that Allow DLL imports is enabled while Confirm DLL function calls is disabled.
  8. Double click the CSV2FXT script in the navigation panel (it’s in the scripts section).
  9. Configure the parameters in the window that pops up.
    • CSV2FXT version – this is a parameter that is only meant to give you a quick indication of what version you have installed. Changing it has no effect.
    • CSV filename – you can leave this blank if the file is named just like the symbol and has a CSV extension (e.g. EURUSD.csv); otherwise, just type the file name.
    • Create HST files – this setting must be true in order to create the HST files that you need for your backtest. You can set it to false if you already generated HST files for the symbol with the same GMT/DST settings and you’re just generating an FXT for a different timeframe. You must create new HST files every time you change the GMT or DST.
      Note: Enabling this setting will create HST files for the whole time span of your tick data file regardless of the time range selected.
    • Spread – the fixed spread of your resulting FXT file, expressed in pips (2.3 will result in a 2.3 pips spread). Leaving it set to the default of 0.0 will make the converter use the current spread of your broker. Please pay attention to the fact that many brokers are widening their spreads during the weekends.
      If you intend to use real spread (the variable spread in your CSV), you can leave this parameter set to 0.0.
      Note: starting from MT4 builds 8xx, the Spread field in the MT4 backtesting pane overrides the spread configured for the FXT unless the FXT is using real spread (see below).
    • Start date and End date – these fields control the time span of the FXT file. You can leave these fields set to their default values (1907.01.01), in which case the converter will just use the whole time range available in the CSV file.
    • Use real (variable) spread – as its name suggests, enabling this parameter will make your resulting FXT use the real (variable) spread from your CSV file.
      The Tick Data Suite will autodetect whether your FXT is using real spread or not so there’s nothing to worry about if you’re using that.
      Note: this parameter makes MT4 disregard the spread configured in the MT4 backtesting UI and use the spread stored in the CSV file in the form of different ask and bid prices.
    • Spread padding – if using real spread, you can pad it by a given number of pips – if you want to pad it by 0.8 pips, just specify 0.8 here.
    • Minimum spread – if any spread is encountered that is lower than the value specified for this parameter, it will be adjusted to this value. This is only applied when using real spread.
    • Commission in pips – if you want your FXT to have a commission, you can configure the desired value here. The figure is round-trip and it is expressed in pips.
      Note: Metaquotes has broken this feature starting from MT4 builds 845 and above. If you need pips commission, I recommend using MT4 build 842 or earlier; alternatively, based on the currency of your backtest you can simply use a money commission that works out to the same amount.
    • Commission in account currency – as an alternative to having the commission in pips, you can also set the commission in money. The value is expressed in base account currency per lot round-trip. If you fill this in, any value specified for Commission in pips will be disregarded.
    • Leverage – changes the leverage of your FXT.
    • FXT GMT offset – if you want your FXT to have a GMT offset other than 0, specify it here.
    • FXT DST setting – the DST setting of your resulting FXT – simply select the DST setting that you would like the file to have. Note that the US DST setting calculates the DST according to the regulations that were applied starting with 2007.
    • CSV GMT offset – the GMT offset of the data in your CSV file. The conversion script is able to autodetect the formats of several free tick data providers and apply the correct setting here, so it’s probably safe to leave it set to “autodetect”. If you get a message in the experts log about the script not being able to identify your tick data source, you can set the CSV GMT offset here manually.
    • CSV DST setting – the DST setting of your CSV. Should be safe to leave it to “autodetect”. Otherwise, use the same guidelines as for the FXT DST setting.
    • Time shift – Enabling this parameter will shift all the generated data 28 years in the past. This is intended for use with EAs that are suspect of having hardcoded days for the purpose of cheating backtesting. The reason behind the 28 year shift is that the calendar is identical when it comes to the days of the week and leap years. This is not a foolproof method and some EAs may have legitimate reasons to yield different results when backtested with a shifted time.
    • Price multiplication factor – All the prices will be multiplied by this value. It’s typically safe to leave this parameter set to 1.0 – don’t change that if you’re converting Forex data. Some brokers use an adapted value for CFDs, indices, metals and so on – instead of the normal price (for instance 12.3456) they will have a value multiplied by a certain value (for example 1234.56); in these cases you have to figure out the multiplier by looking at the chart prices versus the CSV prices.
    • Create M1 FXT, Create M5 FXT, Create M15 FXT, Create M30 FXT, Create H1 FXT, Create H4 FXT, Create D1 FXT, Create W1 FXT, Create MN FXT – These parameters are meant to allow you to create multiple FXT files in a single run. By default, the script will create the FXT for the timeframe of the chart you are running it on, no matter if the parameter for that specific timeframe is enabled or not. Only enable these parameters if you actually need the FXT for a different timeframe.
  10. Click “Ok”. Once you do that, the data generation process will start and it will typically take half an hour to several hours, depending on the data range and volume, possibly even more if you’re using a slow machine. A progress indicator will appear in the upper left side of your chart and when the processing is finished, you will get an alert. During the conversion, some data is being printed in the experts log and if you have any problems with the script it’s probably a good idea to keep an eye on that.

Once you’re done with all the steps above and the script finishes processing, you will be asked whether you want the script to move the files to their proper locations. If you choose Yes, restart the terminal to ensure the HST files are properly synchronised and skip to the next guide (Using the tick data in your backtests). If you choose No, you will have an FXT file and a bunch of HST files in your MQL4\Files folder and before actually using them you need to copy them to the correct location. Proceed with the following steps:

  1. Exit the Metatrader 4 terminal.
  2. Move all .HST files from MQL4\Files to history\[your_server_name]\.
    Pay very close attention if you have multiple server directories in your history folder – you will have to move them into the one that’s correct for active account!
  3. Move the generated FXT file from MQL4\Files to tester\history.

At this point, you’re done with the conversion and setup! You’re now ready to proceed to backtesting, but please note that it’s not as easy as clicking Start in the backtesting user interface. You will have to use some additional tools which are described in the Using the tick data in your backtests section.

If you run into any problems, please head to the FAQ & Troubleshooting page.

Did you find apk for android? You can find new Free Android Games and apps.