Table of contents

Converting to FXT


1. When running CSV2FXT, I get the message “Could not open input file”. What should I do?

That can only be caused by the script trying to open a file that is not there so you either copied the CSV to the wrong folder, named it incorrectly or typed its name incorrectly. Check the following things:

  • You put the CSV file in experts\files.
  • You put the CSV file in the correct MT4 installation folder (if you have more than one).
  • If you left the CsvFile field blank, check that the file is named as your pair and has a csv extension.
  • If you typed something in the CsvFile field, make sure that you typed the full file name including its extension.
  • If your explorer is configured to hide the file extension for known files, your file might be named EURUSD.CSV.CSV and explorer might just show EURUSD.CSV, or your file might be correctly named EURUSD.CSV and your explorer might just show EURUSD. In Windows 7, to work around this issue you can hit ALT in an explorer window, click Tools -> Folder options -> View then uncheck “Hide extensions for known file types”. The procedure is similar for other Windows versions.
  • If you are using Vista and your MT4 installation is in Program Files, I suggest making a copy somewhere else (for instance on your Desktop) and working from that one instead. Vista has something called UAC that can be a royal pain in the ass. You can also disable UAC if you wish, read a few paragraphs below on how to do that.


2. How can I change the fixed spread in an existing FXT file?

Use a hex editor (e.g. WinHex, Neo Hex Editor) and change it at offset 0xFC. Note that it’s going to be displayed in hexadecimal so you’ll probably have to use a calculator.


3. How can I change [some other setting] in an existing FXT file?

Look up the offset in FXTHeader.mqh, it’s displayed next to each setting. Use a hex editor. Note that all values are in little endian format, meaning that if you have a value that exceeds one byte you have to fill in the bytes to its right. For instance, if you want to write 300 in the file you will have to write it as 2C 01.


4. I cannot find the resulting FXT and HST files. Where are they?!

This is typical for Windows 7 / Windows Vista users that run MT4 from their Program Files folder. The issue is caused by the fact that UAC is enabled and these operating systems use folder virtualization. For Windows 7, the resulting files can be found in c:\ProgramData\ typically, while for Windows Vista they can be found in c:\Users\username\AppData\Local\VirtualStore\Program Files\. If they’re not there, just search for *.FXT, they must be somewhere. To get around this problem, either copy your MT4 folder in a location that’s not protected by UAC (e.g. your desktop) or simply disable UAC (type UAC in the start->search box thing and follow the on-screen process).


5. Backtesting an EA with my newly created FXT results in Order Send Error 131. Why?

This might be caused by the lack of a MIN_LOT and LOT_STEP for the symbol in the resulted FXT file. This happens when generating the FXT file with a MT4 client that wasn’t connected to the broker when the script was started. As specified above, your terminal should be connected to your broker when generating an FXT file.


6. What do I do if I get an alert saying Bad CSV Format when I try to convert the CSV I exported from JForex?

This is in all likelihood because you either failed to select a delimiter or selected a dot (.) as the delimiter, so the solution is easy: you go back to JForex, select comma (,) as the delimiter and export the CSV once more. This should be much faster than the first time since the data is cached. If you’re uncertain about the other parameters, take another look at the JForex downloading guide.


7. Is it possible to append tick data to an existing FXT file (and the accompanying HST files)?

No.


8. Is it possible to append tick data to an existing CSV file?

Yes. The CSV2FXT script will disregard duplicate information and even the JForex header line if it is encountered in the middle of the CSV file.

If you are using JForex, you should start your CSV from the time your older CSV ends. You can delete the header row from the new CSV file before concatenating or you can simply skip this step, in which case the CSV2FXT script will skip that line and warn you about it in the experts log. When the export is finished, simply append the new CSV to the older one.

If you are using the PHP scripts, it is ideal to stop your processing at the end of a month. The processing script automatically appends to an existing file so if you resume from the start of the next month your CSV will be perfect. However, you can stop your processing even during the month; for example, if you have a file named EURUSD.csv that ends on 19.03.2012 and then append data starting from 01.03.2012 and ending with 02.04.2012 (e.g. by typing php process_dukascopy_data.php EURUSD 201203 201205 EURUSD.csv), the new data will be appended to your existing CSV and the data between 01.03 and 19.03 will be in your CSV twice. In such a case, the CSV2FXT script will output about 20 errors in your log and spit out an alert about older ticks, but it is smart enough to skip the duplicated data so the resulting FXT should be perfectly fine (although it will take a little bit longer because it has to skip the duplicated period).


9. Why does the CSV2FXT script get stuck as soon as it is started? The progress indicator is not displayed on the chart and the only message displayed in the experts log is “The date column appears to be 0. Sample…”

Most likely this is because you exported the CSV file using JForex but failed to select the comma (,) as the field delimiter as mentioned in the guide. Since for some reason that I fail to grasp the default JForex setting is to use a space as field separator and put several commas at the end of each line, your CSV file is useless and has to be regenerated. The good news is that JForex caches the data so you don’t have to wait for the download once more.


10. How could I change the timeframe of an existing FXT file?

Two steps:

  1. Since the file name contains the timeframe, for instance EURUSD15_0.FXT for an M15 EURUSD FXT file, you have to rename (or copy) the file for the desired timeframe. Assuming you’d want to make it H4, you translate that to minutes (4 hours = 240 minutes) and you rename the file to EURUSD240_0.FXT
  2. Next you have to grab a hex editor and edit the file at offset 0xD0. Change the number to the same one used in the file name in the previous step (but make sure you convert it to hex; using our example above, 240 is 0xF0 so you would have to change it from 0x0F – which is 15 – to 0xF0).

One thing to note that if you perform this change is that the bar count displayed in the results is going to be wrong – you could change that as well but there’s not much point since it has no impact on the backtest.


11. Can I create range bars or Renko bars with CSV2FXT?

I’m afraid the answer is no.

Using the tick data


1. Why are my FXT files being overwritten?

  • If you’re using the free script:
    • You forgot to run the Birt’s patch script. Note that it has to be run every time you restart the MT4 terminal if you wish to backtest using tick data.
    • DLL imports are not enabled (Tools->Options->Expert advisors).
  • If you’re using the Tick Data Suite, you didn’t start the MT4 terminal via tds.exe (and you probably have DLLs disabled so the CSV2FXT script was unable to set the file read-only).


2. Why is my terminal creating an FXT file when I start backtesting?

  • Did you create the FXT file for the currency pair & timeframe that you are trying to use in your backtest?
  • If the answer to the above is yes, did you copy it to the correct location (including the correct MT4 installation folder if you have more than one)?
  • Also see the answer for question #1 above.


3. My backtest runs but I do not get 99% modeling quality. Why?

This is in fact the same question as #2 above.


4. My backtest stops as soon as I click the start button. The backtesting journal tab displays TestGenerator: internal error because the file not opened. What is wrong?

That’s MT4′s way of notifying you that it refuses to overwrite an FXT file that is set read-only. If you’re using the Birt’s Patch script, you probably forgot to run it (keep in mind that you have to run it once after every terminal restart, prior to starting the backtest) or you might be using an outdated version.

If you’re using the Tick Data Suite, you didn’t start the terminal via tds.exe.


5. Why does my terminal crash as soon as I press “start” in the backtest user interface?

  • If you’re not using the latest MT4 build, it’s most likely because the EA was compiled with a build newer than yours and Metaquotes did not think it wise to add ex4 versioning. You can tell this is the problem if attaching the same EA to a chart will also result in a crash. The solution is to use the latest build or get the EA compiled with your build.
  • If you’re using the free script, did you per chance run a backtest prior to running the script?
  • If you’re using the free script, running optimizations will not work.


6. Why do I get a red bar at the end of the backtest even though my modeling quality is 99%?

Because the FXT you are using was created with an older script. It’s nothing to worry about, though – you can safely ignore it.


7. What can I do if my optimization results window is empty even though MT4 appears to run multiple passes correctly?

That means the results you obtained were not profitable. If you wish to see them nonetheless, you can select the Optimization Results tab, right click inside it and deselect “Skip Useless Results”.


8. I am getting empty results (no trades) in all my optimization passes when using the Walk Forward Analyzer. Is there a workaround?

This only happens with some EAs that need the Metatrader 4 terminal to be connected to the broker even when backtesting, for instance Wallstreet Forex Robot or FAP Turbo. To put it simply, since the FXT is already there, the backtest starts too fast. The only solution for this problem is to add an artificial delay, which can be done by using the Configuration program installed with the Tick Data Suite. Just fire up Configuration and increase the Backtest delay factor to something like 3. This will start the backtest with a sensible delay which should be enough for the terminal to connect to the broker. In case it isn’t, feel free to increase it to something like 10. Set it back to 0 once you’re done with that particular EA unless you want to have a permanent delay when backtesting or optimizing with tick data. Note that this option will not have an effect on Metatrader 4 terminals that are already running and you will need to restart these to take advantage of it.


9. Why are all the volumes in my tick data backtest smaller than 1?

It’s because you are using real spread when creating your FXT. When enabling this option, the spread is stored in the volume field. If your strategy makes use of the volume number (which is simply the number of ticks in MT4), you need to use fixed spread or employ other strategies such as counting the number of ticks and storing it in an array.


10. Why does my backtest fail as soon as I attempt to start it with the backtest journal saying “No data for testing.”?

Two possible causes:

  • You enabled Use date and the start and end dates you selected are outside the range covered by your FXT.
  • You are using an FXT larger than 4GB with the Birt’s patch script or an FXT larger than 2GB without removing the limitation, you enabled Use date and the start and end dates you selected are above the 4GB range in the file (respectively above 2GB). Using the Tick Data Suite you can use FXT files of to 208 GB in size.


11. My backtest stops somewhere in the middle, even though the FXT file I created spans a longer time period. How can I fix this?

This is a problem that typically occurs when using the Birt’s patch script and in this scenario it can have two possible causes:

  • You are using a file larger than 4GB; the backtest will stop when it reaches the 4GB limit. There’s also the possibility that you are using a file larger than 2GB and the limitation removal was not enabled.
  • You are using an FXT file with real spread enabled but you failed to enable real spread in the Birt’s patch script.

If this happens and none of the above are the causes, you should first attempt to backtest the MACD EA using your FXT and if it stops at the same point, you should investigate the source CSV in that range and check the log of the CSV2FXT script for any potential errors.


12. How come my backtest results differ from an optimization cycle results if I am using the same parameters?

This only happens when you are using a start/end date for your optimization. Sadly, this is a bug in Metatrader 4: only the first pass of an optimization uses the start and end date you selected; subsequent runs use the full range available in the FXT.

To get the same outcome when backtesting with the parameters for one of the optimization results, you can either make an FXT that spans exactly the period that you want to optimize for, or alternatively you can simply disable Use date when running the backtest for the selected optimization results (if it’s not the parameters for the first run, that is).

  • #101 written by Thiago January 22, 2013 (4 months ago)

    Hello Birt! I am now with another little problem. After that I upgraded the TDS, I can’t open it! Rebooted the laptop, but I still do not get open. What’s going on?

    • #102 written by Thiago January 22, 2013 (4 months ago)

      Hello Birt. This problem I managed to fix it. But still with results without operations, even with 99% quality of modeling. What should be happening?

    • #103 written by Thiago January 22, 2013 (4 months ago)

      Are they the VirtualStore folder within the historical archives that are not working properly? I created a shortcut on the desktop for this folder.

      • #104 written by birt January 23, 2013 (4 months ago)

        If you create a desktop shortcut to the folder it doesn’t eliminate it from within the UAC sphere of influence. You’d have to copy or move it to the desktop completely to get rid of the VirtualStore issue.

        As for TDS not working, please email support and mention the error message that you are receiving when you are trying to start it.

        I’m not sure what you mean with “results without operations” but if you’re not getting any trades in your backtests, you should probably try with a different EA – such as the MACD Sample – using the same dataset; if you have trades when you do that the problem lays with the EA and it might be a good idea to try backtesting it in visual mode and also to check the log for any comments that might indicate what’s wrong.

        Finally, I suggest emailing support with any issues that you are having instead of posting them here. That will result in faster response times because I always prioritize support emails.

        • #105 written by Thiago January 24, 2013 (4 months ago)

          Birt, solved the problem! In fact this working properly, and the problem was I have added the option of lots to do optimization, but it did not work properly because of this. Was just me appearing results with zero zero profit results.

          I’m sorry.

          Since already thank you.

          • #106 written by birt January 24, 2013 (4 months ago)

            No problem at all. I’m glad to hear you were able to figure out the issue.

  • #107 written by Eduardo January 30, 2013 (3 months ago)

    I run backtesting on two different computers and from several MT4 instances and I suffer the same issue on everyone. I have repeated the whole Birt’s procedure with identical results. For any unknown reason, after some times of perfect running (lately no more than one) the backtesting stop giving anything except a quick colored bar indicating the end. When I use visual I can see the time and bars running but no trade at all. If I compile the EA with a new name I get one time of right working. After that again it doesn’t work. Would you please help me? If you want I could give you access to my VPS in order to check it directly. Thanks a lot in advance.

    • #108 written by birt January 31, 2013 (3 months ago)

      That sounds like a problem with your EA. The first thing I would check is the backtesting journal – do you get any error in there? Second, I would advise trying the same data (FXT) with a different EA, for instance the MACD Sample. The third thing I would try is backtesting your EA twice without the TDS.

      If you can’t figure out what’s going based on the above recommendations, please send me an email.

      • #109 written by Luis Eduardo Lowenberg February 4, 2013 (3 months ago)

        As I expected you were right. The problem was on my EA but it only showed its face when occured some external parameters coincidence. Thanks for helping me in focusing properly the issue

  • #110 written by Paul H February 1, 2013 (3 months ago)

    I purchased your Tick Data Suite a few months ago. I downloaded tick data successfully then, but now it seems impossible. I’ve tried the PHP scripts, the 3rd party software and even going into the Dukascopy Historical Data Manager with no luck. Tried from 3 different computers and 2 locations with same result. Is Duckscopy shutting off their free tick data or something?

    • #111 written by birt February 1, 2013 (3 months ago)

      I just downloaded some data right now to verify and it’s working fine for me. If you’re still having problems, try downloading http://www.dukascopy.com/datafeed/EURUSD/2013/00/15/12h_ticks.bi5 in your browser. If you get an error, please send me an email and let me know what exactly is the error or otherwise what is the error that are you getting when trying to use the PHP download script.

  • #112 written by Paul H February 2, 2013 (3 months ago)

    Birt

    I was able to download that file successively and then magically Tickstory began working, but the PHP script or even using the Historical Data Manager @ Duckscopy are still not working. I can gather what I need through Tickstory at this point. Thanks for your help :)

    • #113 written by birt February 2, 2013 (3 months ago)

      Don’t hesitate to email me if you would like to sort out the problems you’re experiencing with the PHP download script, I can assist with that.

  • #114 written by Thiago February 12, 2013 (3 months ago)

    Hello Birt

    Would you know a way to export the results of optimization for .set files?
    How do I do that?

    • #115 written by birt February 13, 2013 (3 months ago)

      Uh, I’m not sure if I understood correctly. Anyway, if you want to save the optimization results, just right click somewhere in the optimization results tab and select Save as report. If you wish to save a .set file with the optimized values, just double click the entry you like in the optimization results tab; the backtest parameters will get populated with the selected values and you can click expert properties to save the .set file.

      • #116 written by Thiago February 13, 2013 (3 months ago)

        Yes … nearly so Birt. I mean how to do this in a way more practice or automatically, as the Walk Forward Analyzer creates inside the MT4.

        • #117 written by birt February 13, 2013 (3 months ago)

          You could inspect the INI files created by the WFA for more information.

  • #118 written by birt February 13, 2013 (3 months ago)

    Vladislav, if you are reading this while waiting for my email, please contact me using a different email address, the one you supplied is not valid.

  • #119 written by trias February 23, 2013 (3 months ago)

    i had run all procedure, when i save as report, modeling quality is : n/a.. what should i do?

    thank you…

    • #120 written by birt February 23, 2013 (3 months ago)

      Make sure you selected the “Every tick” model. If that’s not the problem, please send an email to support.

  • #121 written by gooly March 7, 2013 (2 months ago)

    Hi Birt,
    HELP, can’t back-test any more?!?
    Today this happened, I start TDS starting terminal.exe (as always) and it comes up but as soon as I want to start my back-test I got that windows error:
    Problem signature:
    Problem Event Name: BEX
    Application Name: terminal.exe
    Application Version: 4.0.0.445
    Application Timestamp: 0043c000
    Fault Module Name: terminal.exe
    Fault Module Version: 4.0.0.445
    Fault Module Timestamp: 0043c000
    Exception Offset: 001f7f63
    Exception Code: c0000417
    Exception Data: 00000000
    OS Version: 6.1.7601.2.1.0.256.1
    Locale ID: 3079
    Additional Information 1: ef66
    Additional Information 2: ef66720cc408a692806b8746e318f18b
    Additional Information 3: e4ee
    Additional Information 4: e4eec3fde322fa319364c71a6a66e54e

    Read our privacy statement online:
    http://go.microsoft.com/fwlink/?linkid=104288&clcid=0×0409

    If the online privacy statement is not available, please read our privacy statement offline:
    C:\Windows\system32\en-US\erofflps.txt

    And I _must_ close the terminal.
    After googeling I set the compatibility mode for both (terminal.exe ans TDS to Win Server 2008 – no change.

    What do I have to do?
    What kind of error is BEX that?
    Regards, Gooly

    • #122 written by birt March 7, 2013 (2 months ago)

      You are using MT4 build 445 which is rather old. The EA that you are trying to backtest was probably compiled with a newer version and it only occurred to Metaquotes very recently that such crashes can happen so older version will not warn about newer ex4 files and will just crash instead.

      To verify that this is the problem, you could start the platform without TDS and drag that EA to a chart, which will in all likelihood crash MT4 as well. Alternatively, you could try to backtest the MACD Sample with the same data which will most likely work fine.

      Solution: update to the most recent build (which is 479 at this time).

  • #123 written by Gooly March 7, 2013 (2 months ago)

    Well I updated and try to back-test without TDS and get: TestGenerator: internal error because the file not opened.
    The line before I can read Dysca: loaded successfully (This is my EA, it was compiled without errors)
    The history I created using your TDS-script and I confirmed that the complete history should be created..
    Regards,
    Gooly
    BTW version 445 has been the actual version of my brokers until today!

    • #124 written by birt March 7, 2013 (2 months ago)

      That’s because the FXT file you put in tester/history is read-only. If you wish to backtest without the TDS you will have to delete it.

  • #125 written by gooly March 8, 2013 (2 months ago)

    Hi Birt,
    is it btw possible to back-test without using TDS but with the history-files )m1,m5,m15,..) created by your conversion-script – so to make use of Dukascopy’s Tickdata? I tried but the file in tester\history was emtied at once and then the tester wrote: no history?
    Thanks in advance,
    Gooly

    • #126 written by birt March 8, 2013 (2 months ago)

      Yes, it is possible but not directly supported. I did it many times. You probably did something wrong but I couldn’t say what exactly.

  • #127 written by Gooly March 8, 2013 (2 months ago)

    Ok! I converted the tick-data with create all time-frames, fix spread 0.7 and enabled volume..
    I said to all the questions yes at the end and find at the end all the time-frame history files in tester\history with the same size.
    Now I start the back-test (EURUSD m15) using TDS – fine.
    I closed tds.exe-terminal.exe and re-started just terminal.exe and tried to start visual back-test – queeeck: 2013.03.08 15:06:39 TestGenerator: internal error because the file not opened
    Everything stays as it as before with TDS.

    So what do you do that it works?
    Thanks in advance,
    Gooly

    • #128 written by birt March 8, 2013 (2 months ago)

      That’s because in your tester/history folder you have an FXT file for that currency pair and timeframe that is set to read-only and MT4 can’t overwrite it to generate a new one.

      If you have any further support queries, I would kindly ask that you contact me via email using the address associated with your TDS license (or at least specifying it).

      • #129 written by calli March 8, 2013 (2 months ago)

        Well, this didn’t work. I disabled write-protect of all the files …fxt in tester\history and re-started terminal.exe (without TDS) and got the same queeck: 2013.03.08 16:30:05 TestGenerator: internal error because the file not opened.

        Now I start TDS-terminal.exe again and that works – with not write-protected ..fxt-files. I am a bit confused.
        Regards,
        Gooly

        • #130 written by birt March 8, 2013 (2 months ago)

          Just delete the FXT file for your selected currency pair and timeframe and then start MT4 without the TDS. It should no longer print that error when you start the backtest.

  • #131 written by Daan April 8, 2013 (1 month ago)

    Hi birt,

    Thank you for this great tutorial. I followed all the steps and finally i managed to get a 99% modelling quality at backtesting.
    However i still have one problem. If i try to optimize the parameters in an EA , I only get zero values in all of the optimization results. I also tried it with the macd sample, same problem. The optimization proces produces zero results for all the passes (profit, profit factor, DD are all zero for all the passes). I tried it with 5 different EA’s and all of them have the same problem. Optimizing on a platform with normal broker data doesnt generate this problem. I run the backtest on a mt4 build 482, using the tick data suite.

    • #132 written by birt April 9, 2013 (1 month ago)

      Did you disable “Skip useless results”? Right click the optimization results tab and do that if you didn’t do it already.

      • #133 written by Daan April 10, 2013 (1 month ago)

        I tried that and didnt work. But then I increased the accountsize and risk in the ea’s and that did the trick.
        The marginal ea’s that i have dont react to these changes,still giving zero values. Must have a look at these.

        Is there a way to speedup backtesting in every tik mode?
        Its very slow.

        • #134 written by birt April 10, 2013 (1 month ago)

          Not really, other than optimizing the EA code.

  • #135 written by Thiago April 9, 2013 (1 month ago)

    Hello!

    Anyone ever had problems installing the TDS in Windows Server 2003 R2? I’m having this problem and not getting TDS create the shortcut to the MT4 platform.

  • #136 written by daan April 17, 2013 (1 month ago)

    Hi birt,

    Were can i find the csv file that i make with tickstory lite? I tried to make a csv file from my eurusd tickdata two times, but i have no idea were they are. I looked in the folders that are used in the settings but cannot find them in there.

    • #137 written by birt April 17, 2013 (1 month ago)

      You should ask the creator of TickStory Lite, I cannot provide support for that product. If you put it in Program Files, you might want to try searching your VirtualStore.

      • #138 written by Daan April 18, 2013 (1 month ago)

        Hi Birt,
        Thank you for replying. I wasn’t logged in as an administrator. That is wy I couldn’t find the file.
        If I want to create an FXT file with the CSV2FXT script, do I have to be connected to my broker, or can it also work when the terminal is offline? Because I am a bit concerned that the chartdata created from the csv file will be overwritten.

        • #139 written by birt April 18, 2013 (1 month ago)

          You have to be connected to create the FXT. If you’re concerned about the HST files getting overwritten (MT4 overwrites recent data in them), I would advise making a separate MT4 copy used exclusively for backtesting and setting the HST files read-only. In essence, answer “no” when asked whether you want to copy the files, mark the HST files read-only then copy them manually. Note that if yuo do this, the backtesting terminal is not fit for live trading.

  • #140 written by Daan April 18, 2013 (1 month ago)

    Hi birt,
    Is it possible to make a 1m FXT file from a 1m CSV file using CSV2FXT script?

    • #141 written by birt April 18, 2013 (1 month ago)

      Short answer: no.

      Long answer: if you have some good programming skills it’s possible, but there’s no point – you could simply import it in the MT4 history center and let the MT4 backtesting engine do the interpolation for you.

  • #142 written by Daan April 18, 2013 (1 month ago)

    No wonder CSV2FXT gave me all those errors. Thnx

  • #143 written by Emmarita May 14, 2013 (1 week ago)

    Hi Birt,
    I am using Tickstory Lite with Tick Data Suite. Is it possible with this combination of programs to append new tick data to existing fxt and hst files? I previously downloaded and exported to MT4 4 years of tick data. Now I would like to add the last 4 months to the files for backtesting. Downloading the latestest data from Dukascopy seems easy enough but then do I have to export the entire 4 yrs and 4 months to MT4 or does TDS allow the files to be appended?

    • #144 written by birt May 14, 2013 (1 week ago)

      I’m afraid that it’s currently not possible to append to FXT files and HST files. There are methods to append to existing CSV files, but not to FXT & HST.

      It’s not that it’s not possible at all, it’s just that there’s no software that does it.

  • You may use these HTML tags: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

     

  • Comment Feed for this Post
Go to Top