Download MetaTrader 5
To add comments, please log in or register
Find out how to use widgets at MQL5.community
Wonsuk Song
117
Wonsuk Song 2015.03.31 09:28 

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
2500
Drazen Penic 2015.03.31 10:00  

You need to call EventSetTimer() again.

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

Wonsuk Song
117
Wonsuk Song 2015.03.31 11:03  
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