Need help deciphering HST file
Results 1 to 4 of 4

Thread: Need help deciphering HST file

  1. #1
    I need help deciphering HST documents.

    Mostly, I would like to use perl to extract the datetime, high, low, open and close prices straight from an HST file and create my own chart from it. I (as well as the numerous FF individuals ) will highly appreciate if anybody can show me the way.

    Thanks!

  2. #2
    Hi Burger

    My understanding is that every HST file includes a single header record, followed by a single data record for every period of time, e.g. from the M15 file, there's one document for the OLHCV for each 15 minute interval. The latter are inserted because every period of time so are chained one after the other, and finishes, with no separator/delimiter. The record becomes appended to the file's end.

    The code below is taken from the periodcon.mq4 indior (attached). It gives a good clue loions and regarding the data forms of every field. A hex editor (Google a freeware one like frhed or xvi32 if you don't already have one) can let you step through a HST file and read the data.

    LONG_VALUE is a typical 4-byte signed integer.
    DOUBLE_VALUE is a typical 8-byte floating point value.

    Character areas are padded with s (ASCII 0).

    File name:
    Is the pair (e.g. EURUSD) followed by 1,5,15,30,60,240,1440,10080,43200 for M1, M5, M15, M30, H1, H4, D1, W1, MN respectively.
    Extension = HST

    Data format - to get Header document:
    I) Version = 400 (4-byte LONG_VALUE)
    ii) Copyright tag = (C)opyright 2003, MetaQuotes Software Corp., right padded with s to a length of 64 bytes.
    Iii) Symbol = something like EURUSD, right padded with s to a length of 12 bytes.
    iv) NewPeriodOutput (4-byte LONG_VALUE) = 1,5,15,30,60,240,1440,10080,43200 for M1, M5, M15, M30, H1, H4, D1, W1, MN respectively.
    V) i_digits (4-byte LONG_VALUE) = number of decimal values into a pip, e.g. 4 to most currencies, except 2 for JPY (at least that's how I think it works)
    vi) imesign, lastsync = (both 4-byte LONG_VALUEs) sorry, I'm not certain what these represent.
    Vii) i_unused = 52 bytes worth of s (13 x 4-byte integers).

    Data format - for every Information document:
    is made up of Date/time (4-byte LONG_VALUE), Open, Low, High, Close, Volume (all 8-byte DOUBLE_VALUEs), repeated for every time period:
    I) The date/time worth (i_time) from the data document is the amount of seconds since midnight Jan 1970.
    Ii) Open, Low, High, Close, Volume are floating point values, comprise just what you'd expect (notice that Low is stored before High though).

    Hope I have understood your question, which helps to get you started.

    David
    __________________________________________________ _

    int WriteHistoryHeader()

    series c_copyright;
    int i_digits = Digits;
    int i_unused[13] = 0;
    int variant = 400;

    if (FileHandle lt; 0) return (-1);
    c_copyright = (C)opyright 2003, MetaQuotes Software Corp.;
    FileWriteInteger(FileHandle, version, LONG_VALUE);
    FileWriteString(FileHandle, c_copyright, 64);
    FileWriteString(FileHandle, Symbol(), 12);
    FileWriteInteger(FileHandle, NewPeriodOutput, LONG_VALUE);
    FileWriteInteger(FileHandle, i_digits, LONG_VALUE);
    FileWriteInteger(FileHandle, 0, LONG_VALUE); //timesign
    FileWriteInteger(FileHandle, 0, LONG_VALUE); //last_sync
    FileWriteArray(FileHandle, i_unused, 0, ArraySize(i_unused));
    return (0);

    __________________________________________________ _

    static double d_open, d_low, d_high, d_close, d_volume;
    static int i_time;

    void WriteHistoryData()

    if (FileHandle gt;= 0)
    FileWriteInteger(FileHandle, i_time, LONG_VALUE);
    FileWriteDouble(FileHandle, d_open, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_low, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_high, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_close, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_volume, DOUBLE_VALUE);


    https://forexintuitive.com/attachmen...1973392047.mq4

  3. #3
    Quote Originally Posted by ;
    I need help deciphering HST documents.

    Primarily, I want to use perl to extract the datetime, high, low, open and close prices straight from an HST document and create my own graph out of it. I (as well as the many FF individuals ) will highly appreciate if anybody can show me how.

    Thanks!
    Should you need the datetime, high, low, open and shut, the periodcon.mq4 has an optional input as under:

    OutputCSVFile = 0 / no CSV is output
    OutputCSVFile = 1 / both HST and CSV are output
    OutputCSVFile = 2 / Only CSV is output

    Pick 2 may solve your problem, if I understand you .

    Cheers.

  4. #4
    Thank you for the answer; the sample mq4 file will assist understanding the format too. Should I find any issue, I'll let you know.

    I wonder how 8 byte floating info employed by hst files disagree with php/perl's floating numbers?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information