"cannot set timer(1)" problem in calling iCustom() function in EA - page 2

 
Geoffrey Lemaire:

Dear,

my apologies for reopening this.

i have this issue with forexfactory news indicator and icustom.

when i set ea on chart, i get error cannot set timer.

i do have the mq4, but i have no clue what to do really.


this is the code for the settimer from the indicator:


i have tried putting in onCalculate, but i remain with same issue...

any solution, fix, explanation how to get this working without the error?


thanks

Hi,

You cannot set timer from an indicator and use it in an EA. This is due to the context of operation between an EA and an indicator.

You need to implement another method of time checking within you indicator.

 
Geoffrey Lemaire:

Dear,

my apologies for reopening this.

i have this issue with forexfactory news indicator and icustom.

when i set ea on chart, i get error cannot set timer.

i do have the mq4, but i have no clue what to do really.


this is the code for the settimer from the indicator:


i have tried putting in onCalculate, but i remain with same issue...

any solution, fix, explanation how to get this working without the error?


thanks

Try to replace your EventSetTimer line with this code, and update meif it worked:

//--- create timer
      int error=-1;
      int counter=0;
      int maxTries=3;
      do
        {
         ResetLastError();
         EventSetTimer(RandomTimer);
         error=GetLastError();
         if(error!=0)
           {
            Print("EventSetTimer. Attempt =",counter,"; Error =",error);
            Sleep(1000);
           }
         counter++;
        }
      while(error!=0 && counter<maxTries && !IsStopped());