时间功能函数详解
TimeCurrent(); //返回服务器当前时间
TimeDayOfWeek();//返回当前时间星期几
TimeGMT(); //返回GTM时间
TimeGMTOffset(); //返回时间差
TimeLocal(); //返回电脑上的时间
TimeHour(); //返回时间中的小时
TimeMinute(); //返回时间中的分
TimeSeconds(); //返回时间中的
TimeDay(); //返回当前时间日期
TimeMonth(); //返回时间中的月
TimeYear(); //返回时间中的年
返回服务器的当前时间(交易商地区的时间)
datetime TimeCurrent();
返回当前时间的星期几
int TimeDayOfWeek(
datetime date
)
;
返回GTM时间(国际标准时间)
datetime TimeGMT();
返回国际标准时间与当地时间的时间差
int TimeGMTOffset();
返回当地时间(电脑上时间)
datetime TimeLocal();
返回小时
int TimeHour(
datetime date // date and time
)
;
返回分钟
int TimeMinute(
datetime date // date and time
)
;
返回秒
int TimeSeconds(
datetime date // date and time
)
;
返回日期
int TimeDay(
datetime date // date and time
)
;
返回月份
int TimeMonth(
datetime date // date and time
)
;
返回年份
int TimeYear(
datetime date // date and time
)
;
脚本实例:
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
datetime timecurren = TimeCurrent(); //返回交易商服务器当前时间
datetime timeGMT = TimeGMT(); //返回GTM时间
int timeGMTOffset = TimeGMTOffset(); //返回时间差
datetime timeLocal = TimeLocal(); //返回电脑上的时间
int timeDayOfWeek = TimeDayOfWeek(timeLocal); //返回电脑上的时间星期几
int timeHour = TimeHour(timeLocal); //返回电脑上的时间的小时
int timeMinute = TimeMinute(timeLocal); //返回电脑上的时间的分钟
int timeSeconds = TimeSeconds(timeLocal); //返回电脑上的时间的秒
int timeDay = TimeDay(timeLocal); //返回电脑上的时间的日期
int timeMonth = TimeMonth(timeLocal); //返回电脑上的时间的月份
int timeYear = TimeYear(timeLocal); //返回电脑上的时间的年份
Print("timecurren:",timecurren);
Print("timeDayOfWeek:",timeDayOfWeek);
Print("timeGMT:",timeGMT);
Print("timeGMTOffset:",timeGMTOffset);
Print("timeLocal:",timeLocal);
Print("timeHour:",timeHour);
Print("timeMinute:",timeMinute);
Print("timeSeconds:",timeSeconds);
Print("timeDay:",timeDay);
Print("timeMonth:",timeMonth);
Print("timeYear:",timeYear);
}
实例运行结果:
工欲善其事,必先利其器,交易最重要的是遵守规则,严格执行。关注公众号,学习MQL入门到精通EA教程,学习更多EA编程,畅写属于自己的EA,锻造属于自己的神兵利器。