顺水外汇EA交易网MT4
标题:
实时获取报价自定义指标为何不能实时刷新,恳请高手看看
[打印本页]
作者:
kings12333
时间:
2018-1-11 14:44
标题:
实时获取报价自定义指标为何不能实时刷新,恳请高手看看
各位高手,老师,在网上苦苦寻得一段输出商品报价的指标..但不知为何只能在载入时输出一次,并不能实时输出..(输出文件在MT4的FILE文件中),能否帮改下或是需要如何设置MT4软件才能达到自定义指标实时刷新吗? 谢谢各位..代码如下:
#include
#property indicator_chart_window
int last_write_period=0;
extern int MAX_ROWS = 3000;
extern string START_DATE = "2008-1-1";
int init() {
writelog();
return (0);
}
int writelog() {
int i, cnt, hlog, tm;
string date = Symbol();
date = StringSubstr(date, 0, 1)+StringSubstr(date, 3, 1);
string hour = Symbol();
hour = StringSubstr(hour, 0, 1)+StringSubstr(hour, 3, 1);
string fname = date+"_";
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 = Time[i];
date = TimeToStr(tm, TIME_DATE);
hour=TimeToStr(tm, TIME_MINUTES);
//s output eg:2011.08.2519:00
date= StringSubstr(date,0,4)+"/"+StringSubstr(date,5,2)+"/"+StringSubstr(date,8,2);
if (Open[i]!=0 && High[i]!=0) {
FileWrite(hlog, date, hour,Open[i], High[i], Low[i], Close[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() );
}
作者:
dafubin22
时间:
2018-1-11 15:23
你这个函数是放在加载函数里面,只有指标或者EA刚才加载在盘面时运行一次,你可以把 writelog(); 在OnStart 或者 OnTick()函数里面运行。
作者:
89500568
时间:
2018-1-11 15:59
有用EA赚着钱的吗?
作者:
EUR168
时间:
2018-1-11 17:29
感谢,谢谢;感谢,谢谢
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2