Well, I've seen period_converter.mq4 that comes with Metatrader 4. It's what I want to do to build .hst files for an mql4 indicator/ea. Question now is, how can I get this to do it for more than one time frame?
I've tried this myself in an "easy way". Here's the code. It's a script. So I'm not sure if I convert it to an indicator (or loop this one) how I would 'append' the .hst file. period_converter.mq4 appends. Just see above statement on problem with that one.
I've tried this myself in an "easy way". Here's the code. It's a script. So I'm not sure if I convert it to an indicator (or loop this one) how I would 'append' the .hst file. period_converter.mq4 appends. Just see above statement on problem with that one.
Inserted Code
int start() { //---- Comment("Starting......"); int intTotalCount=10; bool bolLoopFinished=false; int intHandle=FileOpen("myfile.csv",FILE_CSV|FILE_WRITE,','); string strDate; FileWrite(intHandle,"Date","Open","High","Low","Close"); if (intHandle<0) return(0); int intShiftLoop=1, intShift=0; while(!bolLoopFinished) { Comment("Loop: ",intShiftLoop,". Bars: ",Bars); iBarShift(NULL,PERIOD_H1,Time[intShiftLoop],true); intShiftLoop++; if (intShiftLoop>Bars) bolLoopFinished=true; } intShiftLoop=1; intShift=1; bolLoopFinished=false; while(!bolLoopFinished) { Comment("gethering historical values......"); strDate=funcBuildDate(iTime(NULL,PERIOD_H1,intShift)); FileWrite(intHandle, strDate, iOpen(NULL,PERIOD_H1,intShift), iHigh(NULL,PERIOD_H1,intShift), iLow(NULL,PERIOD_H1,intShift), iClose(NULL,PERIOD_H1,intShift)); intShift++; if (intShift>10) bolLoopFinished=true; } FileClose(intHandle); Comment("Indicator finished"); //---- return(0); } //+------------------------------------------------------------------+ string funcBuildDate(datetime dtTime) { //YYYY.MM.DD HH:MM:SS int intYear=TimeYear(dtTime); int intMonth=TimeMonth(dtTime); int intDay=TimeDay(dtTime); int intHour=TimeHour(dtTime); int intMinute=TimeMinute(dtTime); int intSeconds=TimeSeconds(dtTime); string strReturnValue=StringConcatenate(intYear,".",intMonth,".",intDay," ",intHour,":",intMinute,":",intSeconds); return(strReturnValue); }