#include
#property indicator_chart_window
extern string GET_PATH = "C:\Program Files\GET8\TEXT\";
int last_write_period=0;
extern int MAX_ROWS = 300;
extern string START_DATE = "2008-1-1";
int init() {
writelog();
return (0);
}
int writelog() {
int i, cnt, hlog, tm;
string s = Symbol();
s = StringSubstr(s, 0, 1)+StringSubstr(s, 3, 1);
string fname = s+"_";
cnt = Period();
if (cnt==PERIOD_M1) fname = fname+"M1.txt";
if (cnt==PERIOD_M5) fname = fname+"M5.txt";
if (cnt==PERIOD_M15) fname = fname+"M15.txt";
if (cnt==PERIOD_M30) fname = fname+"M30.txt";
if (cnt==PERIOD_H1) fname = fname+"H1.txt";
if (cnt==PERIOD_H4) fname = fname+"H4.txt";
if (cnt==PERIOD_D1) fname = fname+"D1.txt";
if (cnt==PERIOD_W1) fname = fname+"W1.txt";
if (cnt==PERIOD_MN1) fname = fname+"MN.txt";
cnt = CurTime() / (cnt*60);
if (cnt!=last_write_period) {
hlog = FileOpen(fname, FILE_CSV | FILE_WRITE, " ");
if (hlog=0; i--) {
tm = StrToTime(START_DATE)+(MAX_ROWS-i+1)*24*3600;
s = TimeToStr(tm, TIME_DATE);
s = StringSubstr(s,0,4)+"-"+StringSubstr(s,5,2)+"-"+StringSubstr(s,8,2);
FileWrite(hlog, s, Open[i], High[i], Low[i], Close[i], Volume[i], Volume[i]);
}
FileClose(hlog);
last_write_period = cnt;
Print("输出GET数据文件成功.");
Comment(TimeToStr(CurTime(), TIME_DATE), " ", TimeToStr(CurTime(), TIME_MINUTES), ":输出GET数据文件成功.");
}
return (0);
}
int start() {
return ( writelog() );
} |