[新手請教][OnTimer 使用問題] 新评论 kai210034 2016.11.12 10:05 我想要測試OnTimer是否每分鐘會執行一次,所以OnInit()裡面設定EventSetTimer(60),並且在OnTimer()裡加入Print("OnTimer");讓程式每分鐘print "OnTimer"一次,但是在"日誌"裡面卻沒看到印出任何的東西,請問是還少設定什麼嗎?下面附上測試的code,感謝。 //+------------------------------------------------------------------+//| ttttttt.mq4 |//| Copyright 2016, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2016, MetaQuotes Software Corp."#property link "https://www.mql5.com"#property version "1.00"#property strict//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+int OnInit() {//--- create timer EventSetTimer(60); //--- return(INIT_SUCCEEDED); }//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+void OnDeinit(const int reason) {//--- destroy timer EventKillTimer(); }//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+void OnTick() {//--- }//+------------------------------------------------------------------+//| Timer function |//+------------------------------------------------------------------+void OnTimer() {//--- Print("OnTimer"); } 自动交易和策略测试 www.mql5.com MQL5:MetaTrader 5客户端内置的交易策略语言。语言允许编写您自己的自动交易系统,技术指标,脚本和函数程序库 初学者的问题 MQL4 MT4 MetaTrader 4 Plese help me 专家顾问 - 杂项问题 Xiangdong Guo 2016.11.12 16:24 #1 这段代码运行没问题。你可以先把 60 改为 3,这样可以加快调试速度。 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
我想要測試OnTimer是否每分鐘會執行一次,
所以OnInit()裡面設定EventSetTimer(60),並且在OnTimer()裡加入Print("OnTimer");
讓程式每分鐘print "OnTimer"一次,但是在"日誌"裡面卻沒看到印出任何的東西,
請問是還少設定什麼嗎?
下面附上測試的code,
感謝。
//| ttttttt.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
Print("OnTimer");
}