internal void GetHistoricalData (DateTime dtFrom, DateTime dtTo, ref List<Bar> Bars) {
string fPath = @"C:XXXXX" + @"\" + "EURUSD60.hst";
FileStream fileStream = new FileStream (fPath, FileMode.Open);
BinaryReader binaryReader = new BinaryReader (fileStream);
try {
binaryReader.ReadBytes (148);//Headerをスキップ
while(true) {
Bar bar = new Bar ();
bar.currencyPair = "EURUSD";
double binValue = (double)binaryReader.ReadInt64 ();
bar.date = AppParams.dt1970Jan01.AddSeconds (binValue);
bar.open = binaryReader.ReadDouble ();
bar.high = binaryReader.ReadDouble ();
bar.low = binaryReader.ReadDouble ();
bar.close = binaryReader.ReadDouble ();
binaryReader.binaryReader.ReadInt64 ();//volume
binaryReader.binaryReader.ReadInt32 ();//spread
binaryReader.binaryReader.ReadInt64 ();//realVolume
if(Bar.date >= dtFrom && bar.date <= dtTo) Bars.Add (bar);
}
}
catch(EndOfStreamException) {
fileStream.Close ();
fileStream.Dispose ();
binaryReader.Close ();
binaryReader.Dispose ();
}
}
internal Bar{
internal DateTime date;
internal double open;
internal double high;
internal double low;
internal double close;
internal long volume;
internal int spread;
internal long RealVolume;
}
参考
https://github.com/Tim55667757/MT4ForexParser
https://www.fx-automated-system.info/archives/150
https://www.mql5.com/en/articles/1387
https://github.com/Tim55667757/MT4ForexParser/blob/master/mt4forexparser/MT4ForexParser.py
https://github.com/fx-kirin/record_mt4_hst_to_database/blob/master/record_hst_to_mysql.py
https://github.com/bonly/exercise/blob/dccf193a40/2013/201305/20130515_hst_tdx/20130515_hst.go
https://github.com/NewYaroslav/mt4-stooq/blob/bfb9e6102a/include/mt4-hst.hpp
https://github.com/sagittaros/MQL4-portfolio/blob/8c89c0d3d7603b51845011133061e19de29ab838/Normalized%20Tick%20Chart.mq4
https://github.com/sagittaros/MQL4-portfolio/blob/8c89c0d3d7/Renko_ATR_Indicator.mq4
https://github.com/sagittaros/MQL4-portfolio/blob/8c89c0d3d7/Felix-Constant_Tick_Chart.mq4
https://github.com/Jaraiz91/Javier_Araiz_TheBridge/blob/cf582b952f65624687d1cffa7d2c0258f1369346/ML_Project/src/DWX_history.py
https://github.com/flameOnYou/mt4plus/blob/ea57d923cee97bbfc697ebf6a91fb42b833bc22f/main.py
https://github.com/xeoncrypto/MQL4_Custom_Candlestick-/blob/a92ab8914f/CustomChartApi/Mt4CustomChart.mqh
https://github.com/FX31337/FX-Data-Convert-Action/blob/91a095ae87/src/fx-data-convert-from-csv.py