How to prepare your tick data for Metatrader 4
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.
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. This script has been compiled with MT4 build 225 to ensure it works on a wide range of MT4 builds.
Finally, here’s a short guide on how to convert the tick data to an FXT file and a series of HST files:
- If you haven’t done so already, you have to head to the tick data downloads section and download the CSV2FXT binaries archive.
- Copy the files from the zip archive to your MT4 installation folder. There’s a directory structure inside, make sure they land in the proper places (CSV2FXT.mq4 and CSV2FXT.ex4 must be in
experts\scripts, FXTHeader.mqh must be inexperts\include, CsvReader.dll must be inexperts\libraries). Also make sure that you are copying them to the correct folder if you have multiple MT4 installations on your system. - Move the tick data file (the CSV file) to
experts\filesin the same MT4 installation folder. - Open a chart for the pair that you have data for (if you have an EURUSD.csv file, you MUST open an EURUSD chart).
- 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.
- 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).
- 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.
- Double click the CSV2FXT script in the navigation panel (it’s in the scripts section).
- 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.CsvFile– 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.CreateHst– 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.StartDateandEndDate– these fields control the time span of the FXT file. The format of the StartDate and EndDate fields is YYYY.MM.DD. You can leave these fields blank, in which case the converter will just use the earliest, respectively the latest date available in the CSV file.UseRealSpread– as its name suggests, enabling this parameter will make your resulting FXT use the real (variable) spread from your CSV file.
If using the loader script, you MUST enable real spread when running it to be able to use such FXT files. 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.SpreadPadding– 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.PipsCommission– if you want your resulted FXT to have a commission, you can configure the desired value here. The figure is round-trip and it is expressed in pips.Leverage– changes the leverage of your FXT.FXTGMTOffset– if you want your FXT to have a GMT offset other than 0, specify it here.CSVGMTOffset– 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.FXTDST– the DST setting of your FXT. Type 0 for no DST, 1 for US DST, 2 for European DST. Note that the US DST setting calculates the DST according to the regulations that were applied starting with 2007.CSVDST– the DST setting of your CSV. Should be safe to leave it to “autodetect”. Otherwise, use the same guidelines as for the FXTDST.TimeShift– 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.CreateM1,CreateM5,CreateM15,CreateM30,CreateH1,CreateH4,CreateD1,CreateW1,CreateMN– 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.
- Click “Ok”. Once you do that, the data generation process will start and it will typically take 20 to 45 minutes, 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 synchronized 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 experts\files folder and before actually using them, you need to copy them in the correct location. Proceed with the following steps:
- Exit the Metatrader 4 terminal.
- Move all .HST files from
experts\filestohistory\[your_server_name].
Pay very close attention if you have multiple server directories in yourhistoryfolder – you will have to move them into the one that’s correct for active account! - Move the generated FXT file from
experts\filestotester\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.
- #3 written by Swell February 9, 2012 (3 months ago)
- #4 written by adept February 10, 2012 (3 months ago)
Hi Birt,
great stuff! However, there’s one improvement I can think of. Waiting for Metatrader to finish the conversion from csv to fxt on a certain timeframe before being able to kick off the conversion on another timeframe is a bit of an inconvenience. Would it be possible to write a script that does the conversion for a whole set of timeframes?
Keep up the brilliant work!
- #5 written by birt February 10, 2012 (3 months ago)
- #6 written by Harald February 11, 2012 (3 months ago)
Just did it and it works fine for me. I added 9 additional fields to select if a timeframe FXT should be done or not and then it does all selected FXTs in one run.
I will send the modified CSV2FXT to Birt for code review. I leave it to him to integrate it or to put the file as “unsupported 3rd party work” in his DL section. Have fun…- #7 written by birt February 11, 2012 (3 months ago)
- #8 written by Harald February 11, 2012 (3 months ago)
fully agree. It will not save time, it is just to avoid waiting for the script finish and then start the next and again and again. It’s a short-term solution.
Your way would be much smarter but you indicated “in the future”, whenever this is. So I just wanted to let others benefit from the “workaround” way.
- #12 written by Victor February 11, 2012 (3 months ago)
As you probably know Dukascopy has changed historical data format adding to time part of it the fraction of seconds.
When can you adapt your soft to that change?
Would it be possible for you to create some sort of instrument to merge old data with new one (just not to re-download the whole lot of history)?Thank you
- #13 written by birt February 11, 2012 (3 months ago)
Dukascopy hasn’t changed the format to add the seconds fractional part. It has been like that since I first encountered it back in 2009. CSV2FXT does not need to be adapted to that change, it is already processing such dates correctly. Just as a side note, Metatrader 4 is only able to process seconds, not also second fractions; however, there can be multiple ticks in the same second so there’s no problem whatsoever as long as they are in order (which they are).
As for your other question, you don’t have to re-download the whole history. Most download methods will automatically resume from where they finished last run. However, you need to export it to a CSV and transform it to an FXT. Creating a tool for appending to an FXT and to its corresponding HST files is completely impractical from a programming effort point of view. When it comes to the CSV files, the PHP download scripts already support a basic degree of appending while the other methods are not of my design so I can’t really do much about them.
- #14 written by Mike7P February 20, 2012 (2 months ago)
Hi Birt, I’m fairly new to FX and find this site really valuable reading.
I’m trying to learn the art of Back-testing using Tick Data and have read through these pages several times.
I’ve downloaded Tick Data csv files for 0 pairs from Dukescopy using their jforex client. I then downloaded your CSV2FXT binaries file and placed the individual folders as shown in the instructions on this page.
I opened a EUR/USD M15 chart as this is the first file I put in experts\files folder, then went through parameters and checked Allow dlls was set. However when i clicked ok i got an error message saying “Can’t open input file experts\files\EURUSD.csv
I’m using MT4 version 409 downloaded from Metaquotes website.
I’ve also downloaded the trial version of your Tick Data Suite to try, but am unable to do so unless i can convert the data.
Any help or advice would be very welcome.
ThanksMike7P
- #15 written by birt February 20, 2012 (2 months ago)
Please read the FAQ & Troubleshooting page. The error basically means the file is not there which could be due to several reasons detailed there.
- #16 written by Mike7P February 21, 2012 (2 months ago)
The file was in the right folder but I realized that I had not renamed it to just EURUSD. After renaming it and putting onto an M15 chart again I thought that everything was OK as the progress counter slowly made its way to 100%.
When I received the process finished message, I went back to experts\files to look for the converted hst & fxt files but they weren’t there.
Thinking they may have been put into the folders history\servername & tester\history automatically, I went looking there.They weren’t there either. So I the put Win 7 search into action. Eventually all the hst as well as the fxt files were found in c: users\Mike\AppData\Local\VirtualStore\Program Files (x86)\MetaTrader\experts\files.
Before I go any further can you tell me if you think this is the correct location, and do I now just need to move the fxt file to tester\history?
I thank you in advance for your patience and hope you don’t think I’m asking dumb questions.
Regards
Mike7P- #17 written by birt February 21, 2012 (2 months ago)
The file is probably named EURUSD.csv now but it used to be named EURUSD.csv.csv. Windows Explorer hides the extension of the file types it recognizes as mentioned in the FAQ.
As for the files ending up in the VirtualStore folder, there is an item in the FAQ about that as well, I suggest reading it because it could make your life easier (the files would show up in the right place). Anyway, the VirtualStore folder is certainly not where the files should be. As the guide says, you need to copy the FXT to [MT4 install path]\tester\history and the HST files to [MT4 install path]\history\[active broker server].
- #19 written by Jason February 20, 2012 (2 months ago)
Hello Birt,
Thank you for all this information. I’m having a bit of trouble though. I’ve downloaded my tick data via JForex. I follow the instructions above, and what happens is this: it runs through once, i.e. the percentage calculator goes from 1% to 100%, then the alert says “Processing for EURUSDfo has finished.” Afterwards, it continues to spit out alternating alerts “Bad CSV format” & “Error opening CSV file. Aborting.” I assumed this was normal as it should have already imported the data once, maybe it was getting confused about replicate data. Anyhow, I look in the files directory but there were no HST or FXT files created. There is one FXT file in the tester/history directory from an hour ago or so, and I’m not sure if that had anything to do with this.
Other than specifying the CSV filename, I’ve left all of the other inputs for the EA on default. And there are no log files being created in the logs directory either. Any ideas where I’m going wrong?
Thanks,
-Jason - #21 written by Neo February 25, 2012 (2 months ago)
Hi Birt, I just read your new guide on converting the CSV file to an FXT. I noticed that now you suggest HST files should be created along with the FXT…but it sounded like the reason for this is mainly so that indicators can respond/function properly. I normally don’t create HST files because the EAs I’m using don’t use indicators, or if they do, they only use 1 or 2. Is it still safer/better to create the HST files along with the FXT?
I also notice that when creating an FXT file for the M15 TF, the HST files are all relatively small except for the M15 HST file. The M15 HST file is over 1 Gig, while the other HST files range from 1kb to 16MBs. The guide says that you don’t need to recreate HST files for each new FXT file you create (if you need FXT files for different TFs), but seeing that the HST file is bigger than 1 Gig and the other TF HST files are so small…I wonder if the HST files for the other TFs are reliable to go along with an FXT file for a different TF.
Hope that makes sense. Thanks for your time.
Neo
- #22 written by Neo February 25, 2012 (2 months ago)
I’m sorry…in my haste I was foolish enough to not notice that the large M15 file (which I thought was a HST file) was really the FXT file (for the M15)…and the actual HST file for the M15 was small, so please disregard my 2nd question above. The M1 HST file is the biggest (16MB) and the size then systematically goes down all the way to 1kb for the Monthly TF HST file.
Neo
- #23 written by birt February 25, 2012 (2 months ago)
Was about to reply that something is wrong but by what you’re saying in the 2nd post, everything sounds about right.
If your EA is using indicators, it’s a must to copy the HST files. I’m not entirely sure if the MT4 backtesting engine uses the HST files for indicators on the current timeframe (I believe that’s what it’s doing) but it definitely uses them if your indicator is using a different timeframe.
What happens if you don’t copy the HST files is that the values of your indicators are offset by X hours, depending on the GMT offset difference and DST settings. Not to mention that even if you get the GMT/DST right, the bars in your history may have formed slightly different from the bars in the tick data. In other words, everything that depends on the indicators is likely completely wrong.
I suggest making a few tests with & without copying the HST files. Let us know your results.
- #25 written by RG February 27, 2012 (2 months ago)
- #27 written by KK March 5, 2012 (2 months ago)
-Getting following error messages when I run script:
“bad csv format”
“unable to understand date format”-Double checked all instructions, went through all above comments, and troubleshoot and still no luck on solution. Fairly certain did everything right. Got data from Dukascopy history page. Thank you.
- #29 written by KK March 6, 2012 (2 months ago)
- #30 written by birt March 6, 2012 (2 months ago)
Given your lines, I will guess that you opened the files with Excel and copy/pasted from there. If that’s not the case and your exported file has spaces instead of commas, then you need to reexport it with commas somehow.
Also, further guesswork based on the dates in your posted lines indicates that you only downloaded the data for 04.03.2012, which is what confuses the CSV2FXT script. Simply put, the script cannot know if the month is 04 or 03 and it needs ticks for at least 2 different days in the input to figure it out. I suggest downloading a sample that contains more data or, in case you only want to test a single day, a sample for which the date format can be precisely determined (e.g. 19.02.2012).
- #32 written by Dude March 10, 2012 (2 months ago)
- #34 written by Michal March 11, 2012 (2 months ago)
Hi,
I am trying to convert tick data downloaded from dukascopy Jforex. Following your steps, I put all files into directories and renamed the name of csv file to CAJPY, with visible extension. I clik ok after having set the script values and it does nothing. No error message but no progress bar either.
Journal in MT4 says, Script CSV2FXT CADJPY Daily;loaded successfully, after clicking ok, Script CSV2FXT CADJPY Daily;removed. What could be the problem?Michal
- #35 written by birt March 11, 2012 (2 months ago)
- #36 written by Michal March 11, 2012 (2 months ago)
Everything is placed correctly, one thing though, that i found to be not correct is that the folder “includes” is actually “include”.
What I could find in the log txt file was only this:
1;113;D:\MT4InstallFolder\MT-4-8-Demo\experts\scripts\CSV2FXT.mq4;2064:20;’
1;39;;;Function “ReadAndCheckHeader” is not referenced and will be removed from exp-file- #37 written by birt March 11, 2012 (2 months ago)
- #38 written by Michal March 11, 2012 (2 months ago)
- #39 written by birt March 11, 2012 (2 months ago)
- #40 written by Michal March 11, 2012 (2 months ago)
15:24:05 CSV2FXT EURJPY.,Daily: loaded successfully
15:24:12 CSV2FXT EURJPY.,Daily inputs: CSV2FXT_version_0.29=”"; CsvFile=”"; CreateHst=true; ValueInfo=”All spreads & commissions are in pips regardless of the number of digits.”; Spread=3.3; DateInfo1=”Use YYYY.MM.DD as date format for start/end date.”; DateInfo2=”Leave the fields empty to use the whole CSV file.”; StartDate=”"; EndDate=”"; UseRealSpread=false; SpreadPadding=0; PipsCommission=0; Leverage=100; GMTOffsetInfo1=”Specify the target GMT Offset.”; GMTOffsetInfo2=”The FXT GMT offset is the GMT offset of the resulting FXT file.”; FXTGMTOffset=0; GMTOffsetInfo3=”The CSV GMT offset is the GMT offset of the input tick data CSV file.”; CSVGMTOffset=”autodetect”; DSTInfo1=”0 – no DST, 1 – US DST, 2 – Europe DST”; FXTDST=0; CSVDST=”autodetect”; TimeShiftInfo=”See the guide for more info.”; TimeShift=false; CreateM1=false; CreateM5=false; CreateM15=false; CreateM30=false; CreateH1=false; CreateH4=false; CreateD1=true; CreateW1=false; CreateMN=false;
15:24:12 CSV2FXT EURJPY.,Daily: CSV delimiter: comma (,).
15:24:12 CSV2FXT EURJPY.,Daily: cannot load library ‘CsvReader.dll’ (error 126)
15:24:12 CSV2FXT EURJPY.,Daily: expert stopped
15:24:12 CSV2FXT EURJPY.,Daily: uninit reason 0
15:24:12 CSV2FXT EURJPY.,Daily: removed
- #41 written by Michal March 11, 2012 (2 months ago)
- #42 written by birt March 11, 2012 (2 months ago)
- #43 written by Michal March 11, 2012 (2 months ago)
- #45 written by Michal March 11, 2012 (2 months ago)
- #47 written by Michal March 11, 2012 (2 months ago)
- #49 written by Shinobi March 18, 2012 (2 months ago)
Hi Birt!
thanks for your tools.
I have some future index tick data, but the format of the csv is not compatible with your converter scripts.
What format does the unconverted input csv file need to have in order to be processable by your script? (mine at the moment has: date, time, price, size).
Could you maybe put a sample csv file to the download section?Then it should be easy to convert input files in order to work with your script!
Thank You!
shinobi
- #50 written by birt March 18, 2012 (2 months ago)
- #51 written by Shinobi March 18, 2012 (1 month ago)
- #52 written by birt March 19, 2012 (1 month ago)
At the moment, you can’t use it with the data you have unless you re-export it as mentioned above. Why don’t you send me a sample file (e.g. the first megabyte of your data) via the contact form and I’ll see what could be done?
As a warning, though: your data isn’t very reliable if it doesn’t have both the bid and ask prices.
- #53 written by Shinobi March 20, 2012 (1 month ago)
- #54 written by birt April 9, 2012 (1 month ago)
To follow up on this, I didn’t have the time to explore the possibility of adapting CSV2FXT to work with the data you have and given my current workload, I don’t expect it to happen anytime soon. I would advise looking for an alternate method (such as merging the date + time fields in a single field separated by a space and duplicating the price field). You could probably do that with any database software, likely even with MS Access.
- #55 written by JBente March 26, 2012 (1 month ago)
- #57 written by JBente March 26, 2012 (1 month ago)
- #59 written by JBente March 26, 2012 (1 month ago)
- #60 written by birt March 26, 2012 (1 month ago)
I assume you are using JForex. Please take the time to read the JForex guide, it is explained there.
- #61 written by JBente March 26, 2012 (1 month ago)
- #62 written by birt March 26, 2012 (1 month ago)
Oh, yeah – my bad, it looks like you did everything right. However, the Bid, Ask and their volumes should have their decimals separated by a dot (e.g. a line should look like 2012.01.01 23:06:41.470,1.29473,1.29461,0.75,1.32). I thought JForex was free of locale issues after the update but it seems that is not the case.
I suggest temporarily switching to a locale that is using a dot (.) as the decimal separator (such as the English locale) and exporting the CSV again. The lines in the CSV should look as the one I posted in the previous paragraph.
- #63 written by Neo March 26, 2012 (1 month ago)
Last night I converted 2 years of tick data (Dukascopy CSV, 2010-2012) of the EURJPY using the CSV2FXT script (v0.31). Right when the script started work, I got this Alert message: “Your CSV file appears to have a lot of damaged prices. You should check the experts log for more information.”
I’ve only converted EU and GU tick data so far, this was the first time to do another pair, but is this message something that we see often? I ran a scan with the tick data (just a short, 14 day test) to see if the modeling quality was 99%…which it was. But I’m concerned about this message and wonder if some of the data during the 2 year period I’m working with might be faulty?
Thanks for your time,
Neo- #64 written by birt March 26, 2012 (1 month ago)
if you take a look at your experts log, it has more details such as the dates and times where the data is incorrect. You can then proceed to check the CSV and find out what is wrong.
A message gets printed in the log when the price jumps by more than 10% from a tick to the next; if that message is printed 20 times, the alert comes up and further messages are suppressed. All the ticks that you are warned about like this are skipped. This usually happens when using the Dukascopy web CSV export which appears to have a bug. Also, the USDJPY and EURJPY Dukascopy data (these are the pairs that I know of) have an issue on 2007.04.01 and jump to a price of 1.x and then gradually go up to the real price. I’m guessing the latter was the problem in your case, you can just take a look at the log or confirm by searching for 2007.04.01 in your CSV file. If that’s the case, the solution is to simply select 2007.04.02 as the starting date in CSV2FXT.
- #65 written by Neo March 27, 2012 (1 month ago)
Thanks for your timely answer, Birt.
I’m gonna step out on a limb here and say that I think this new issue we’re having (the alert warning; “Your CSV file appears to have a lot of damaged prices. You should check the experts log for more information.”) is being caused by the latest release of the CSV2FXT script. I just finished testing with 2 brokers and 3 different currency pairs and still get the same alert…even though just 2 days ago I converted the same CSV file (using the previous version of your CSV2FXT script) with no issue and no warning message.
I just finished testing the GU and EJ, neither of them dating back to 2007, just with data from 2010-2012. The alert message comes up the instant you hit the OK button on the script, before it even shows 1% done…and you never see this alert again, even though it takes about 10 minutes to finish running the script. So, I don’t think it’s running into bad tick data along the way as its going through the CSV file and creating the HST and FXT files.
Unfortunately I don’t have the previous version of the CSV2FXT script, as I overwrote the file when I d/l the new one yesterday…so I can’t confirm that it is indeed v.0.31 of the CSV2FXT script.
In 2 hours my optimized back tests will finish, the ones I am doing with the FXT file I created regardless of the alert message I got. I’ll look through the experts log once it’s done and look for dates and times where the data looks incorrect.
Best Regards,
Neo- #66 written by birt March 27, 2012 (1 month ago)
This could not have happened with any older version of the script because it’s a warning that was introduced in v0.31.
Basically, what happens is this:
- the ask & bid of each tick is checked against the ask & bid of the previous tick
- if the ask or bid of the new tick are 10% smaller or bigger than the ask respectively bid of the previous tick, an error message is printed in the experts log with the date and time of the erroneous tick and the tick is skipped
- if the ask differs from the bid by over 10%, the same error message is printed in the experts log and the tick is skipped
- if 20 such error messages were printed, the alert you mentioned comes up and warns you about the integrity of your CSV fileWhat’s very important to notice about the above is that erroneous ticks are skipped so your FXT files are probably ok even if your CSV isn’t.
Anyway, I made a v0.32 just for this purpose. The only difference from v0.31 is that it clearly displays the ask & bid for the skipped tick as well as for the previous tick in the experts log. Please use this version and you will get a better idea of what is wrong in the CSV file without having to actually open it and search inside.
- #67 written by Neo March 28, 2012 (1 month ago)
Thanks, Birt. I’m testing the new v0.32 script now. I got the same Alert the instant I hit the OK button on the script. Is this normal?–or should this message come up a little bit later, once the CSV is actually being read–and during the FXT/HST creation process? It just seems that if the ask and bid are 10% different (to warrant the alert), this alert would pop up during the process that the large CSV file is being read and not only once, the instant the script is started.
- #69 written by Neo March 28, 2012 (1 month ago)
Anyway, I made a v0.32 just for this purpose. The only difference from v0.31 is that it clearly displays the ask & bid for the skipped tick as well as for the previous tick in the experts log. Please use this version and you will get a better idea of what is wrong in the CSV file without having to actually open it and search inside.
How do I check the experts log to look for this information? Do I look in the Journal tab of the Tester section in MT4?–or do I look in the MT4/tester/logs folder and open the most recent .log text file and scroll there? I have looked in both of these places, but I am not finding information on skipped ticks…is there a specific message I should look for to find them?
Thank you
- #70 written by birt March 28, 2012 (1 month ago)
Your MT4 client has a section (typically at the bottom) that contains a few tabs: Trade, Account History, Alerts, Mailbox, Experts, Journal. The “Experts” tab contains the experts log. The expert log is also available as a file in experts/logs.
Since you’re converting files and not backtesting anything, the backtest journal (in tester/logs) has nothing to do with it.
- #71 written by Neo March 28, 2012 (1 month ago)
Don’t mean to eat up all the bandwidth here, but since I’ve been working with tick data conversion all day, using the new script, I thought I’d share what I’ve been experiencing.
First of all, I download all my tick data from Dukascopy’s JForex, using the exact instructions from the tutorial page.
I’ve now tested the CSV2FXT v0.32 script with 3 currency pairs, on 2 different brokers (one with MT4 Build 416 and one with Build 418). I’m working with data from 2011-2012. No matter what TF I create the HST/FXT files for and no matter what currency pair I use, or which broker I use, I always get the Alert “Your CSV file appears to have a lot of damaged prices. You should check the experts log for more information.”
2 days ago I did this same procedure for 2 of the same currency pairs, for the same time block (2011-2012) with no issue (using the pre 0.32 version of the script).
I don’t mind the Alert message if it’s telling me something I should know, but I’m concerned if the FXT/HST files are not accurate as a result. The pair I’m testing now has results that don’t look reliable. Even though it’s printing 99% modelling quality, I’m getting one scan with 254 trades, then the next scan with 90 trades, then the next with a totally different number. This doesn’t seem right.
Just hoping to make sense of it.
- #72 written by birt March 28, 2012 (1 month ago)
Like I said before, it would have been impossible to get the alert with CSV2FXT v0.30 or earlier because there was no such error checking. Trying a different timeframe or broker will have no effect because the error is in the CSV. The alert message is telling you something that you should know. You will find more information in the experts log and you will be able to investigate the CSV file based on that and potentially even manually correct the errors in it.
As for your optimization results, they probably have nothing to do with the data and everything to do with the EA you are optimizing and the settings you selected for optimization. I suggest verifying the CSV based on the info in the experts log to identify the source of the problem.
- #73 written by birt March 28, 2012 (1 month ago)
- #75 written by WiZARD March 28, 2012 (1 month ago)
- #76 written by birt March 28, 2012 (1 month ago)
- #77 written by JBente March 28, 2012 (1 month ago)
- #78 written by Neo March 28, 2012 (1 month ago)
You would set the GMT offset to 2 and the DST to 2 (European Daylight Savings Time). That will keep you of FXDD’s time all year. If you would rather have the time change to DST when the US changes (there is a 10 day to 2 week period when the US and Europe are out of sync with DST), then change the DST to 1 instead of 2.
Best Regards
- #79 written by Neo March 28, 2012 (1 month ago)
You would set the GMT offset to 2 and the DST to 2. This will keep your history files and FXT file always on FXDDs time, no matter what time of year. There is a 10-day to 2-week period every 6 months when the DST change comes along, when the US and Europe is out of sync. If you want your candles/bars to always reflect the London open at the correct London open time, then choose DST 2. If you want the candles/bars to always reflect the NY open at the correct NY time, then choose DST 1. This will only affect that interim period of 10 days to 2 weeks when the US and Europe are out of sync.
Regards
- #80 written by JBente March 28, 2012 (1 month ago)
Hi, is this configuration ok?
CSV2FXT_version_0.28=””; CsvFile=””; CreateHst=true; ValueInfo=”All spreads & commissions are in pips regardless of the number of digits.”; Spread=0.03; DateInfo1=”Use YYYY.MM.DD as date format for start/end date.”; DateInfo2=”Leave the fields empty to use the whole CSV file.”; StartDate=””; EndDate=””; UseRealSpread=false; SpreadPadding=0; PipsCommission=0; Leverage=100; GMTOffsetInfo1=”Specify the target GMT Offset.”; GMTOffsetInfo2=”The FXT GMT offset is the GMT offset of the resulting FXT file.”; FXTGMTOffset=2; GMTOffsetInfo3=”The CSV GMT offset is the GMT offset of the input tick data CSV file.”; CSVGMTOffset=”autodetect”; DSTInfo1=”0 – no DST, 1 – US DST, 2 – Europe DST”; FXTDST=2; CSVDST=”autodetect”; TimeShiftInfo=”See the guide for more info.”; TimeShift=false; CreateM1=false; CreateM5=false; CreateM15=false; CreateM30=false; CreateH1=false; CreateH4=false; CreateD1=true; CreateW1=false; CreateMN=false;- #81 written by birt March 28, 2012 (1 month ago)
The spread is expressed in pips. Configuring a spread of 0.03 is the equivalent of forcing a spread of 0 pips. If you want a spread of 3 pips, you have to type 3. If you want a spread of 0.3 pips, you have to type 0.3. A “pip” is widely accepted as the smallest price change on a 4 digit broker.
As for the GMT & DST offsets, they appear correct if you want to use the European DST regulations.
- #82 written by JBente March 28, 2012 (1 month ago)
- #84 written by JBente March 28, 2012 (1 month ago)
- #85 written by birt March 28, 2012 (1 month ago)
- #86 written by luca April 3, 2012 (1 month ago)
- #88 written by kk April 3, 2012 (1 month ago)
Hi Birt,
I downloaded dukascopy data with JForex client. The time period for the data was 1 jan 2012 to 2 april 2012. I then generated the .hst and FXT files problem free. The files generated are all less than 1 Kb in size. Is that expected? Now, after having copied the created files into their correct locations, I launched mt4, immediately closed all surfacing charts, clicked File then Open Offline and viewed the Open Offline Chart window. The history data for all time frames was from 1970 jan 1 to 1970 jan 1. I am wondering why the dates are incorrect. Could u please comment at your convenience? Thank u Sir.- #89 written by birt April 3, 2012 (1 month ago)
- #90 written by Murray April 15, 2012 (1 month ago)
Hi Birt,
I know it is possible to pad the variable dukascopy spreads by say half a pip or a pip, but is it possible to reduce it by using a negative number, say 0.2 or 0.4 pips? Obviously this could cause problems if the spread was already very low and the reduction made it negative, but if I am careful of this, is it possible?
Regards,
Murray- #91 written by birt April 15, 2012 (1 month ago)
Yes, it is, but you should add a line that doesn’t permit the spread to go below 0. I will add it to the next CSV2FXT. I added it to v0.34 but I won’t release the new version yet because there are not enough major changes to warrant it.
In CSV2FXT v0.33, after the block:
if (UseRealSpread) {
ExtSpread = dblAsk - tick_price + SpreadPadding * Point;
}
(should be around line 521).You should add a line so it looks like this:
if (UseRealSpread) {
ExtSpread = dblAsk - tick_price + SpreadPadding * Point;
if (ExtSpread < 0) ExtSpread = 0;
}
- #93 written by Ron Elitzur April 21, 2012 (3 weeks ago)
- #96 written by Ron Elitzur April 22, 2012 (3 weeks ago)
- #99 written by Future April 24, 2012 (3 weeks ago)
Hi birt thanks for this tutorial and tools, i’ve got a strange bug with CSV2FXT: when i attach it on EUR/USD M5 i don’t see any progress indicator in the upper left side of my chart but i think the script is working because if i try to run CSV2FXT again it say something like: “do you really want to stop CSV2FXT and run CSV2FXT on EUR/USD M5″ Any idea?
- #100 written by Future April 24, 2012 (3 weeks ago)
- #101 written by birt April 26, 2012 (3 weeks ago)
- #102 written by Future April 26, 2012 (3 weeks ago)
14:22:41 MetaTrader – Alpari UK build 419 started (Alpari (UK) Ltd.)
14:22:44 ’28787′: login
14:22:45 ’28787′: login
14:22:46 ’28787′: previous successful authorization performed from xxx.xxx.xxx.xx
14:22:57 Script CSV2FXT EURUSD,M5: loaded successfully
14:24:04 Script CSV2FXT EURUSD,M5: removed
14:24:07 MetaTrader – Alpari UK build 419 stoppedi’m running Birt’s CSV2FXT script v0.33 binaries.
- #103 written by birt April 26, 2012 (3 weeks ago)
- #104 written by Future April 26, 2012 (2 weeks ago)
sorry :
14:22:57 CSV2FXT EURUSD,M5: loaded successfully
14:23:29 CSV2FXT EURUSD,M5 inputs: CSV2FXT_version_0.33=”"; CsvFile=”EURUSD_Ticks_2010.01.01_2010.12.31.csv”; CreateHst=true; ValueInfo=”All spreads & commissions are in pips regardless of the number of digits.”; Spread=0; DateInfo1=”Use YYYY.MM.DD as date format for start/end date.”; DateInfo2=”Leave the fields empty to use the awhole CSV file.”; StartDate=”"; EndDate=”"; UseRealSpread=false; SpreadPadding=0; PipsCommission=0; Leverage=100; GMTOffsetInfo1=”Specify the target GMT Offset.”; GMTOffsetInfo2=”The FXT GMT offset is the GMT offset of the resulting FXT file.”; FXTGMTOffset=0; GMTOffsetInfo3=”The CSV GMT offset is the GMT offset of the input tick data CSV file.”; CSVGMTOffset=”autodetect”; DSTInfo1=”0 – no DST, 1 – US DST, 2 – Europe DST”; FXTDST=0; CSVDST=”autodetect”; TimeShiftInfo=”See the guide for more info.”; TimeShift=false; CreateM1=false; CreateM5=false; CreateM15=false; CreateM30=false; CreateH1=false; CreateH4=false; CreateD1=false; CreateW1=false; CreateMN=false;
14:23:29 CSV2FXT EURUSD,M5: CSV delimiter: comma (,).
14:23:29 CSV2FXT EURUSD,M5: The date column appears to be 0. Sample: 2010.01.03 22:04:20.643.1.43025.1.4299.7.5.1.3
14:24:04 CSV2FXT EURUSD,M5: shutdown by timeout
14:24:04 CSV2FXT EURUSD,M5: uninit reason 4
14:24:04 CSV2FXT EURUSD,M5: removed- #105 written by birt April 26, 2012 (2 weeks ago)
Looks like you used JForex to download the data and you failed to set the delimiter to a comma as specified in the JForex tick data guide. You will have to recreate your CSV file using the correct setting.
- #108 written by Harrison April 25, 2012 (3 weeks ago)
Hi
I’m confused by what settings I should have for FXTGMTOffset combined with FXTDST. I am in the UK, which is GMT/BST (BST is GMT+1). HOWEVER, the UK is generally one hour behind Western Europe for the whole year because everyone goes onto DaylightSavingTime at the same time. My broker is AlpariUK, who have recently standardised their datafeed servers onto EET (EASTERN Europe Time) – this is two hours ahead of UK time.
I’ve downloaded tick data from Dukascopy (Western Europe) and you say your script can automatically detect which timezone the data comes from.
Question: Is the FXTDST value supposed to include the value from FXTGMTOffset? E.g. Since I’m in the UK, FXTGMTOffset = 0, FXTDST = 1?
Or are these values supposed to take into account what server time a particular broker is on? E.g. For AlpariUK, FXTGMTOffset = 2, FXTDST = 3?
Please advise!
- #109 written by birt April 26, 2012 (3 weeks ago)
You are not supposed to set the GMT and DST offset according to your local timezone unless you really want that for some reason. They are customizable to allow tailoring the data to the settings of particular brokers but it’s not really mandatory to do that.
The script automatically detects the GMT and DST settings of the input data and outputs files with GMT 0 and no DST. If you wish to configure a different GMT offset or a different DST setting for your output files, all you have to do is change the settings you mentioned. Before proceeding with that, please read their descriptions carefully, the DST parameter does not work as you surmised.
Bottom line, it depends on the EA you’re backtesting: if it doesn’t care about the time, you can just disregard the GMT/DST. If it expects DST-shifted data, you have to enable DST according to what it expects; if it uses H4 or D1 indicators, you should probably match the GMT offset of your broker due to the bar shift issue.
- #111 written by socalengineer May 3, 2012 (1 week ago)
Hi Birt,
My broker (FXCM) has provided me with tick data using the historic data downloader:
http://www.fxcmapps.com/standalone/historical-data-downloader/It doesn’t seem that the tick data I download from this app can be used with your CSV to FXT converter because it is in a different format. The script complains about the format. I have tried both MT4 and CSV formats that are available from the downloader. Any suggestions on this other than to make my own script or modify the data to be read by your script?
- #112 written by birt May 3, 2012 (1 week ago)
- #113 written by socalengineer May 6, 2012 (1 week ago)
Date Time OpenBid HighBid LowBid CloseBid OpenAsk HighAsk LowAsk CloseAsk Total Ticks
4/27/2012 4:05:36 1.32023 1.32023 1.32023 1.32023 1.32034 1.32034 1.32034 1.32034 0
4/27/2012 4:05:37 1.32021 1.32021 1.32021 1.32021 1.32033 1.32033 1.32033 1.32033 0
4/27/2012 4:05:37 1.3202 1.3202 1.3202 1.3202 1.32031 1.32031 1.32031 1.32031 0
4/27/2012 4:05:37 1.32019 1.32019 1.32019 1.32019 1.3203 1.3203 1.3203 1.3203 0Thanks Birt!
- #114 written by birt May 6, 2012 (1 week ago)
That’s a very weird format with a ton of useless data. Does it support any other format or is that the only one?
Anyway, I’m afraid I won’t modify the CSV2FXT script to support that format anytime soon because it’s a tick data source that is not free, it is not popular at all and it would require very extensive changes. If that’s the only supported format, your best bet (and the easiest option) is to write a parser/converter that goes through the whole CSV and outputs a new file using the format
MM/DD/YY HH:MM:SS,Bid,AskAlternatively, you could ask FXCM to add that as an export format to their software.
- #115 written by socalengineer May 6, 2012 (1 week ago)
- #116 written by birt May 6, 2012 (1 week ago)
- #117 written by socalengineer May 12, 2012 (5 days ago)
Hmmm… I have changed the format to as you have specified but am still getting a “cannot understand date format” error from the script file. Please help. This is what the file looks like now:
Date,Time,Bid,Ask
04/27/2012,04:05:36,1.32023,1.32034
04/27/2012,04:05:37,1.32021,1.32033
04/27/2012,04:05:37,1.3202,1.32031
04/27/2012,04:05:37,1.32019,1.3203Thanks in advance Birt!
- #118 written by socalengineer May 12, 2012 (5 days ago)
- #120 written by legion May 4, 2012 (1 week ago)
Hi Birt,
I dont know what went wrong but when i convert using your old script, its no problem. When i use your new script CSV2FXT, i only can convert a 1,377,230kb csv file to get 397,771kb fxt file which i cannot used. If i used your old script, i get a 1,440,252kb fxt file which can be used
2012.05.05 02:40:08 Convert_JForex_to_FXT EURUSD,M1: removed
2012.05.05 02:40:08 Convert_JForex_to_FXT EURUSD,M1: uninit reason 0
2012.05.05 02:40:08 Convert_JForex_to_FXT EURUSD,M1: Alert: Processing for EURUSD has finished.
2012.05.05 02:40:08 Convert_JForex_to_FXT EURUSD,M1: 28361862 ticks added. 375456 bars finalized in the header
2012.05.05 02:35:13 Convert_JForex_to_FXT EURUSD,M1 inputs: CsvFile=”"; CreateHst=false; Spread=0; DateInfo1=”Use YYYY.MM.DD as date format for start/end date.”; DateInfo2=”Leave the fields empty to use the whole CSV file.”; StartDate=”"; EndDate=”"; GMTOffsetInfo1=”Specify the target GMT Offset.”; GMTOffset=0; RealSpreadInfo1=”The real spread will only work with the dedicated loader.”; UseRealSpread=true; VolumeInfo1=”Only enable this if you actually need it.”; UseRealVolume=false;
2012.05.05 02:35:04 Convert_JForex_to_FXT EURUSD,M1: loaded successfully2012.05.05 02:27:33 CSV2FXT EURUSD,M1: removed
2012.05.05 02:27:33 CSV2FXT EURUSD,M1: uninit reason 0
2012.05.05 02:27:31 CSV2FXT EURUSD,M1: 7833000 ticks added.
2012.05.05 02:26:02 CSV2FXT EURUSD,M1: Starting to process EURUSD 2012.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Starting to process EURUSD 2011.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Last date in file: 2012.04.30 23:59:59 (file: 2012.04.30 23:59:59.353)
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Autoconfigured source GMT to 0 and source DST to 0.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Your tick data source seems to be Dukascopy, downloaded via JForex.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Date format identified: YYYY.MM.DD hh:mm:ss. Elucidating value: 2011.05.02 00:00:00.191
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Bid volume column: 4. Sample: 1.00000000
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Ask volume column: 3. Sample: 1.00000000
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: We have two volume columns. Arranging them in the same order as the ask/bid prices.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Bid price column: 2. Sample: 1.4814
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Ask price column: 1. Sample: 1.4820
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Column 4 is a numeric field.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Column 3 is a numeric field.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Column 2 is a numeric field.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: Column 1 is a numeric field.
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: The date column appears to be 0. Sample: 2011.05.01 21:01:06.092
2012.05.05 02:22:48 CSV2FXT EURUSD,M1: CSV delimiter: comma (,).
2012.05.05 02:22:48 CSV2FXT EURUSD,M1 inputs: CSV2FXT_version_0.34=”"; CsvFile=”"; CreateHst=true; ValueInfo=”All spreads & commissions are in pips regardless of the number of digits.”; Spread=0; DateInfo1=”Use YYYY.MM.DD as date format for start/end date.”; DateInfo2=”Leave the fields empty to use the awhole CSV file.”; StartDate=”"; EndDate=”"; UseRealSpread=true; SpreadPadding=0; PipsCommission=0; Leverage=100; GMTOffsetInfo1=”Specify the target GMT Offset.”; GMTOffsetInfo2=”The FXT GMT offset is the GMT offset of the resu
2012.05.05 02:22:28 CSV2FXT EURUSD,M1: loaded successfully - #122 written by Resin May 6, 2012 (1 week ago)
Hello, everyone. I am getting an error “The date column appears to be 0. Sample…”. I am using an MT4 v401 and data downloaded from Dukascopy. I have looked inside the csv file and the date is present there…
What can be the issue? I am also getting the same problem with a version 419 when I use the TDS (trial)..
I have done conversion using the Birt’s script last year and all worked fine..
Thank you.- #123 written by birt May 6, 2012 (1 week ago)
If the script hangs at that, most likely you forgot to set comma as the delimiter when exporting the CSV from JForex. If you inspect it, it will have some 4-5 commas at the end of the line. If that’s the case, the only solution is to reexport the CSV from JForex, selecting the comma as the delimiter.
If that’s not the issue, please paste the relevant lines from your experts log here and also the first 2-3 lines from your CSV.
- #124 written by Resin May 7, 2012 (1 week ago)
- #125 written by birt May 7, 2012 (1 week ago)
- #126 written by legion May 12, 2012 (4 days ago)
- #130 written by legion May 13, 2012 (3 days ago)
- #132 written by legion May 13, 2012 (3 days ago)
Problem is EA still trading, vendors said no problem with EA. Maybe The MT4 i use to convert data and do backtest is outdated which still version 229 and no connection? But converting data and backtest dont need the connection to broker, right? Or maybe the “new” duskacopy data i download got problem?
- #133 written by birt May 13, 2012 (3 days ago)
- #134 written by legion May 14, 2012 (2 days ago)
- #135 written by birt May 14, 2012 (2 days ago)
131 = invalid volume (you’re probably trying to open a trade of 0.01 lots and the minimum volume is 0.1)
4051 = invalid lots amount (probably trying to open e.g. 0.11 when the lot increment is 0.1)The errors have nothing to do with the tick data and everything to do with the min lot and lot increment of the broker that you used to generate the FXT and with the EA ability to adjust to different lot conditions.
I would suggest trying to backtest it with a fixed lot of 1.0.
- Comment Feed for this Post
Didn't find any related posts :(
Hi Birt,
I did all the things you say on this page, but I get an error when converting the .csv to FXT. The error messsage on Metatrader is:
2012.02.06 23:28:23 CSV2FXT EURUSD,Daily: function ‘CsvIsLineEnding’ call from dll ‘CsvReader.dll’ critical error
Hope you are able to take a look into it.
Thanks.
Mattijs Christiaanse