Table of contents
- Converting to FXT
- When running CSV2FXT, I get the message “Could not open input file”. What should I do?
- How can I change the fixed spread in an existing FXT file?
- How can I change [some other setting] in an existing FXT file?
- I cannot find the resulting FXT and HST files. Where are they?!
- Backtesting an EA with my newly created FXT results in Order Send Error 131. Why?
- What do I do if I get an alert saying Bad CSV Format when I try to convert the CSV I exported from JForex?
- Is it possible to append tick data to an existing FXT file (and the accompanying HST files)?
- Is it possible to append tick data to an existing CSV file?
- 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…”
- How can I change the timeframe of an existing FXT file?
- Can I create range bars or Renko bars with CSV2FXT?
- Using the tick data
- Why are my FXT files being overwritten?
- Why is my terminal creating an FXT file when I start backtesting?
- My backtest runs but I do not get 99% modeling quality. Why?
- 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?
- Why does my terminal crash as soon as I press “start” in the backtest user interface?
- Why do I get a red bar at the end of the backtest even though my modeling quality is 99%?
- What can I do if my optimization results window is empty even though MT4 appears to run multiple passes correctly?
- I am getting empty results (no trades) in all my optimization passes when using the Walk Forward Analyzer. Is there a workaround?
- Why are all the volumes in my tick data backtest smaller than 1?
- Why does my backtest fail as soon as I attempt to start it with the backtest journal saying No data for testing.?
- My backtest stops somewhere in the middle, even though the FXT file I created spans a longer time period. How can I fix this?
- How come my backtest results differ from an optimization cycle results if I am using the same parameters?
Converting to FXT
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
CsvFilefield blank, check that the file is named as your pair and has a
- If you typed something in the
CsvFilefield, 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.
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.
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.
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).
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.
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)?
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.
- 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
- 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.
I’m afraid the answer is no.
Using the tick data
- 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).
- 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.
This is in fact the same question as #2 above.
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.
- 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.
Because the FXT you are using was created with an older script. It’s nothing to worry about, though – you can safely ignore it.
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.
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.
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.
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.
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).