Data exportation - in search of a script

trendisyourfriend

Junior member
Messages
16
Likes
0
Hi there,

I'd like to be able to export historical datas for a given timeframe (say H1) but for a list of currency pairs (1 file by currency pair) that i could define one time. Is it possible to do this in MT4 with a single click of a mouse ?

I'd like to automate this process as doing it by hand every day for 28 currency pairs is quite long.

Thanks
 
Hi,

I can do it for you, unfortunely not for free :whistling

But my free advise is to omit MetaTrader and extract them directly from *.hst files located in \MetaTrader 4\history dir, works much faster. MQL script will also work for this.

Cheers,
Kriss.
 
Hi,

I can do it for you, unfortunely not for free :whistling

But my free advise is to omit MetaTrader and extract them directly from *.hst files located in \MetaTrader 4\history dir, works much faster. MQL script will also work for this.

Cheers,
Kriss.

Kriss, thank you for your reply,

Would you mind telling me what type of text editor i need in order to open these ".hts" files as they seem to be encoded in an unknown format (at least to me). Are these files generated automatically when i open a chart for a given timeframe or must i export them manually ?

Again a big thanks.
 
Hi,

Its not encoded, its saved as a binary data, you can view it with any hex-editor.
You are lucky because I wrote few months ago simply program for viewing metatrader history files. Just install, File -> Get, choose any *.hst file, specify time period, and you can view it.

But you should open those files in your program.

Here you have history file header format (C/C++):
Code:
struct HistoryHeader_t
{
	int    version;         // database version
	char   copyright[64];   // copyright info
	char   symbol[12];      // symbol name
	int    period;          // symbol timeframe
	int    digits;          // the amount of digits after decimal point in the symbol
	time_t timesign;        // timesign of the database creation
	time_t last_sync;       // the last synchronization time
	int    unused[13];      // to be used in future
};

and quote format:

Code:
#pragma pack(push,1)
struct RateInfo_t
{
	time_t ctm;             // current time in seconds
	double open;
	double low;
	double high;
	double close;
	double vol;
};
#pragma pack(pop)

If you are including <windows.h> then before it put:
Code:
#define _USE_32BIT_TIME_T
because normaly time_t in windows is 64bit and inside *.hst files is saved as a 32bit value.

You must write program for it, there is no other way, you can write MQL4 script, should be much easier for non-programmer (much slower also) in MQL4 you have
int FileOpenHistory( string filename, int mode, int delimiter=';') function for it.

Cheers,
Kriss.
 

Attachments

  • HistQuotes.zip
    143.8 KB · Views: 249
Last edited:
Are these files generated automatically when i open a chart for a given timeframe or must i export them manually ?
This files are generated when you download data in history center (press F2) and they are updated when new bars are available.

If you want to download very long history, for example few years one minute GBP/USD history, go first to terminal, tools->options then charts and set max bars to very large value (1000000000)
 
Top