I’m clearly missing something because the timer is not beating appropriately for me in the ST.
Here’s my test program:
//+------------------------------------------------------------------+
//| test.mq5 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#include <Files\File.mqh>
#include <Files\FileTxt.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
Print ("TT " + total_ticks);
File.Close();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
int total_ticks;
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
CFileTxt File;
void OnTimer()
{
total_ticks = total_ticks+1;
MqlDateTime time_now;
TimeToStruct(TimeCurrent(),time_now);
int fh = File.Open("times.txt",FILE_COMMON|FILE_WRITE|FILE_READ|FILE_BIN,9);
FileSeek(fh,0,SEEK_END);
FileWriteString(fh, TimeCurrent() +"\r\n");
}
//+------------------------------------------------------------------+
…and here’s a bit of the output (many beats at the same time and then missing beats at other times):
2017.03.20 05:42:59
2017.03.20 05:53:59
2017.03.20 05:54:59
2017.03.20 05:54:59
2017.03.20 05:54:59
2017.03.20 05:54:59
2017.03.20 05:54:59
2017.03.20 05:59:59
2017.03.20 05:59:59
2017.03.20 06:02:00
2017.03.20 06:02:59
2017.03.20 06:03:30
2017.03.20 06:03:30
2017.03.20 06:03:30
2017.03.20 06:03:30
Thank you.