Download MetaTrader 5

Making variable EventSetTimer function?

To add comments, please log in or register
Wonsuk Song
121
Wonsuk Song  

Hi! I'm trying to build my first EA.

Is there anyone who knows how to build the variable EventSetTimer function?

As  you know, EvenSetTimer() is usually called in init() with fixed int variable, like EventSetTimer(60);..

But I'd like to make the 60sec to variable one by using another variable. So I tried like below... 

 

int Timer; 

on  OnInit()

   {

         Timer = 1;

         EventSetTimer(Timer);

              ................

    } 

 void OnTimer()

    {

    ....

    Timer = 30;

     ....

     } 

 

How could I solve this issue? Thank you in advance for your comments. 

Drazen Penic
2740
Drazen Penic  

You need to call EventSetTimer() again.

Each time you want to change timer interval you should call EventSetTimer() with new interval.

Wonsuk Song
121
Wonsuk Song  
drazen64:

You need to call EventSetTimer() again.

Each time you want to change timer interval you should call EventSetTimer() with new interval.

Genius! I called EventSetTimer in onTimer function again, and it solved problem very easily.

Thank you very much!! 

To add comments, please log in or register