You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
For clarity for myself, at least, and anyone else that has an interest . . .
[...]
then the bars array (single-byte justification) . . . total 60 bytes
I read version 400 with success thanks to your post. The problem is the above spec somehow doesn't work for version 401.
I read 7 * 8 + 4 bytes for each candle data, then I unpack them as Long, 4 * Double, Long, Integer, Long (LD4LIL) and the ohlc data is garbled for some reason. I tried different endianness (because I'm on mac) but it still reads garbage into the doubles.
With version 400 I read 4 + 5 * 8 and unpacked them as Integer, 5 * Double and the numbers were correct.
edit: it worked, here's the working code: https://gist.github.com/nurettin/e8c77336b91f2c00e302
From the PeriodConverter Script that comes with MetaTrader 4.0 Build 840, the header says it is version 401 and it looks like this:
//--- write history file header
FileWriteInteger(ExtHandle,file_version,LONG_VALUE);
FileWriteString(ExtHandle,c_copyright,64);
FileWriteString(ExtHandle,c_symbol,12);
FileWriteInteger(ExtHandle,i_period,LONG_VALUE);
FileWriteInteger(ExtHandle,i_digits,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteArray(ExtHandle,i_unused,0,13);
Which would come out to 8+64+12+(4*8)+(4*13) = 168 bytes
I read version 400 with success thanks to your post. The problem is the above spec somehow doesn't work for version 401.
I read 7 * 8 + 4 bytes for each candle data, then I unpack them as Long, 4 * Double, Long, Integer, Long (LD4LIL) and the ohlc data is garbled for some reason. I tried different endianness (because I'm on mac) but it still reads garbage into the doubles.
With version 400 I read 4 + 5 * 8 and unpacked them as Integer, 5 * Double and the numbers were correct.
edit: it worked, here's the working code: https://gist.github.com/nurettin/e8c77336b91f2c00e302
version 401 uses the MqlRates structure, which looks like this:
{
datetime time; // Period start time
double open; // Open price
double high; // The highest price of the period
double low; // The lowest price of the period
double close; // Close price
long tick_volume; // Tick volume
int spread; // Spread
long real_volume; // Trade volume
};
(6*8) + 4 + 8 = 60 bytes
version 401 uses the MqlRates structure, which looks like this:
{
datetime time; // Period start time
double open; // Open price
double high; // The highest price of the period
double low; // The lowest price of the period
double close; // Close price
long tick_volume; // Tick volume
int spread; // Spread
long real_volume; // Trade volume
};
(6*8) + 4 + 8 = 60 bytes
I created a ruby library called hst for both reading and writing 400 and 401 versions:
https://rubygems.org/gems/hst
And then import in JavaScript used for import in HTML page and showing custom chart in mobile (works in Firefox only)...
https://github.com/eltomjan/ETEhomeTools/tree/master/MetaTrader
Anyone interested in that app (would like to sell it).
In case can publish also JS import, but principles are same as in C# version...
Strange is Droid has different format, but same version and extension ?? Probably authors do not care about external processing or compatibility...
Hello fellow traders ... And maybe programmers...
I have just finished to code some macro vba for Excel so that I can analyze my hst files. Obviously, this is only the whole file processing. If one wants to add moving averages, or any other indicator, it will be up to him/her to create a new macro. By the way, if so, I recommend to make the calculations starting from the most recent bars (down in the file excel) and going further back (high in the file excel) until the period is greater than the number of bars left.
First of all, it is a file Excel and you have full access to the code so if you are not sure of what the macro does, have a look at the code.
2nd, this line is the line of your file and its directory :
Open "Path\*.hst" For Binary Access Read As intFileNum
so if your file is in C:\test directory and is EURUSD1.hst your line will have to be
Open " C:\test\EURUSD1.hst" For Binary Access Read As intFileNum
3rd, please don't modify or delete any of the Functions, it will prevent the macro from working.
4th, I have left the first 2 lines and the last 3 columns (tick#, spread, real volume). These can be either delete manually after the macro has run or be not executed by putting in comment (' at the beginning of the line) the lines:
Cells(3, 7) = "Tick count"
Cells(3, 8) = "Spread"
Cells(3, 9) = "Real volume"
Cells(3 + sample_pos, 7) = volume_val
Cells(3 + sample_pos, 8) = spread_val
Cells(3 + sample_pos, 9) = realvol_val
Thank you Simon Gniadkowski for sharing.