| / | Forum |
|
brave0heart
2006.10.17 04:00
Hi, I have two questions about the period converter
1) The file format that it writes looks strange, if opened directly. Is there a guide to reading it? Is it in a language other than English, or compressed or something. Here is a brief sample from the top of the file for EURUSD 1 minute data: Copyright © 2005, Alpari Ltd.EURUSD'Ð@ |aó?@aó?àMbó?ÀMbó?.@@'Ð@ÀMbó?åaó?À¶bó?ÀMbó?$@|'Ð@ÀMbó? Ø_ó?àMbó? Ø_ó?5@¸'Ð@€A`ó 2) While running it, how would I extract moving averages. I am only including part of the period converter, and with //** I am indicated where I think a person should be able to extract a simple moving average, for instance. If I can do this, then I could write my own file in asci and in a format I could read. Thanks //+------------------------------------------------------------------+ //| Period_Converter.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property show_inputs #include <WinUser32.mqh> extern int ExtPeriodMultiplier=3; // new period multiplier factor int ExtHandle=-1; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { int i, start_pos, i_time, time0, last_fpos, periodseconds; double d_open, d_low, d_high, d_close, d_volume, last_volume; int hwnd=0,cnt=0; //---- History header int version=400; string c_copyright; string c_symbol=Symbol(); int i_period=Period()*ExtPeriodMultiplier; int i_digits=Digits; int i_unused[13]; //---- ExtHandle=FileOpenHistory(c_symbol+i_period+".hst", FILE_BIN|FILE_WRITE); Alert(c_symbol+i_period+".hst"); if(ExtHandle < 0) return(-1); //---- write history file header c_copyright="(C)opyright 2003, MetaQuotes Software Corp."; FileWriteInteger( ExtHandle, 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 ); //timesign FileWriteInteger( ExtHandle, 0 , LONG_VALUE ); //last_sync FileWriteArray( ExtHandle, i_unused , 0, 13 ); //---- write history file periodseconds=i_period*60; start_pos =Bars- 1 ; d_open =Open[ start_pos] ; d_low =Low[ start_pos] ; d_high =High[ start_pos] ; d_volume =Volume[ start_pos] ; //---- normalize open time i_time = Time[start_pos]/periodseconds; i_time *= periodseconds; int y = 1; for(i = start_pos-1; i>=0; i--) { y = y + 1; Comment(y); time0 = Time[i] ; if(time0>=i_time+periodseconds || i==0) { if(i==0 && time0<i_time+periodseconds) { d_volume+=Volume[0]; if (Low[0 ] < d_low ) d_low = Low[ 0] ; if (High[0 ] > d_high ) d_high = High[ 0] ; d_close = Close[0] ; } last_fpos=FileTell(ExtHandle); last_volume=Volume[i]; //Alert(Minute()," -- ",i_time, " ",d_close); //Sleep(1000); //** can I someone get the EMAs here?? //***************************** FileWriteInteger( ExtHandle, i_time , LONG_VALUE ); FileWriteDouble( ExtHandle, d_open , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_low , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_high , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_close , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_volume , DOUBLE_VALUE ); FileFlush( ExtHandle ); cnt++; if(time0>=i_time+periodseconds) { i_time=time0/periodseconds; i_time*=periodseconds; d_open=Open[i]; d_low=Low[i]; d_high=High[i]; d_close=Close[i]; d_volume=last_volume; } } else { d_volume+=Volume[i]; if (Low[i]<d_low) d_low=Low[i]; if (High[i]>d_high) d_high=High[i]; d_close=Close[i]; } |
|
Interview with Michael Bullock (Zonker) Constantly plowing back all the profit and scaling up the position is pure suicide trading on a real account. But that is not relevant, this is a competition, over 250 competitors, and only three walk away with anything. You do whatever it takes to maximize your chances to be in that Top Three. I'm not sure you can talk about risk in the context of the competition, risk implies you might lose something, but here there is only a chance to gain for those who beat the odds. |
|
brave0heart
2006.10.17 06:31
brave0heart wrote: Hi, I have two questions about the period converter 1) The file format that it writes looks strange, if opened directly. Is there a guide to reading it? Is it in a language other than English, or compressed or something. Here is a brief sample from the top of the file for EURUSD 1 minute data: Copyright © 2005, Alpari Ltd.EURUSD'Ð@ |aó?@aó?àMbó?ÀMbó?.@@'Ð@ÀMbó?åaó?À¶bó?ÀMbó?$@|'Ð@ÀMbó? Ø_ó?àMbó? Ø_ó?5@¸'Ð@€A`ó 2) While running it, how would I extract moving averages. I am only including part of the period converter, and with //** I am indicated where I think a person should be able to extract a simple moving average, for instance. If I can do this, then I could write my own file in asci and in a format I could read. Thanks //+------------------------------------------------------------------+ //| Period_Converter.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property show_inputs #include <WinUser32.mqh> extern int ExtPeriodMultiplier=3; // new period multiplier factor int ExtHandle=-1; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { int i, start_pos, i_time, time0, last_fpos, periodseconds; double d_open, d_low, d_high, d_close, d_volume, last_volume; int hwnd=0,cnt=0; //---- History header int version=400; string c_copyright; string c_symbol=Symbol(); int i_period=Period()*ExtPeriodMultiplier; int i_digits=Digits; int i_unused[13]; //---- ExtHandle=FileOpenHistory(c_symbol+i_period+".hst", FILE_BIN|FILE_WRITE); Alert(c_symbol+i_period+".hst"); if(ExtHandle < 0) return(-1); //---- write history file header c_copyright="(C)opyright 2003, MetaQuotes Software Corp."; FileWriteInteger( ExtHandle, 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 ); //timesign FileWriteInteger( ExtHandle, 0 , LONG_VALUE ); //last_sync FileWriteArray( ExtHandle, i_unused , 0, 13 ); //---- write history file periodseconds=i_period*60; start_pos =Bars- 1 ; d_open =Open[ start_pos] ; d_low =Low[ start_pos] ; d_high =High[ start_pos] ; d_volume =Volume[ start_pos] ; //---- normalize open time i_time = Time[start_pos]/periodseconds; i_time *= periodseconds; int y = 1; for(i = start_pos-1; i>=0; i--) { y = y + 1; Comment(y); time0 = Time[i] ; if(time0>=i_time+periodseconds || i==0) { if(i==0 && time0<i_time+periodseconds) { d_volume+=Volume[0]; if (Low[0 ] < d_low ) d_low = Low[ 0] ; if (High[0 ] > d_high ) d_high = High[ 0] ; d_close = Close[0] ; } last_fpos=FileTell(ExtHandle); last_volume=Volume[i]; //Alert(Minute()," -- ",i_time, " ",d_close); //Sleep(1000); //** can I someone get the EMAs here?? //***************************** FileWriteInteger( ExtHandle, i_time , LONG_VALUE ); FileWriteDouble( ExtHandle, d_open , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_low , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_high , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_close , DOUBLE_VALUE ); FileWriteDouble( ExtHandle, d_volume , DOUBLE_VALUE ); FileFlush( ExtHandle ); cnt++; if(time0>=i_time+periodseconds) { i_time=time0/periodseconds; i_time*=periodseconds; d_open=Open[i]; d_low=Low[i]; d_high=High[i]; d_close=Close[i]; d_volume=last_volume; } } else { d_volume+=Volume[i]; if (Low[i]<d_low) d_low=Low[i]; if (High[i]>d_high) d_high=High[i]; d_close=Close[i]; } I have one other question about the above. As I move through the loop, how can I extract the time for each trade and pass it to a variable? Thanks Steve |