EventSetTimer: Internal error

 

Hi,

I have the following code for a oneshot timer:

int OnInit()
{
   if (EventSetTimer(3) == false) {
      int lastError = GetLastError();
      Print("Timer init Failed: ", ErrorDescription(lastError));
   }
   return(INIT_SUCCEEDED);
}

void OnTimer()
{
   Print("Handling Timer");
   EventKillTimer();

}

I get "Timer init Failed: internal error".

Am I doing anything wrong ? Why would a simple EventSetTimer fail ?

 

The following code works for me (created using MT4 indicator wizard with your code pasted into it minus ErrorDescription()) so there doesn't appear to be anything wrong with the code itself.  Unfortunately not familiar enough with MQL & MT to say what might cause it to fail, but invariably when something doesn't make sense it's time to revisit assumptions.

 

#property copyright ""
#property link      ""
#property version   "1.00"
#property strict
#property indicator_separate_window
//--- input parameters
input int      Delay = 3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   if (EventSetTimer(3) == false) {
      int lastError = GetLastError();
      Print("Timer init Failed: ", lastError);
   }
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   Print("Handling Timer");
   EventKillTimer();
//---
   
  }
//+------------------------------------------------------------------+
 
maindoor:

Hi,

I have the following code for a oneshot timer:

I get "Timer init Failed: internal error".

Am I doing anything wrong ? Why would a simple EventSetTimer fail ?




Are you this code in a script ?
 
angevoyageur:

Are you this code in a script ?

No, In an expert Advisor.

Sometimes the timer works and most of the times it doesn't.

 
I tried it in an EA and an indicator OnTimer works fine in both. Have you tried upgrading to the latest build 654 ?
 
SDC:
I tried it in an EA and an indicator OnTimer works fine in both. Have you tried upgrading to the latest build 654 ?

I am demo'ing with oanda and the latest they have is build 646.

I'm still at the same level, works sometimes but doesn't work most of the time.

I'm on virtualbox with host win7 and guest win-xp. mt4 is installed on win-xp.

 
Why not just installed it on Win 7 directly? No need to use Win Xp.
 
maindoor:

I am demo'ing with oanda and the latest they have is build 646.

I'm still at the same level, works sometimes but doesn't work most of the time.

I'm on virtualbox with host win7 and guest win-xp. mt4 is installed on win-xp.

You can still upgrade if make a second account on your terminal to MQ demo server 443
Reason: