Run a timer every 15minutes at 9:00 - 9:15 - 9:30 - 9:45 - 10:00 -10:15 .. and so on..

 

Hello friends,


I want to run a timer every 15minutes at fixed 15min candle times.

for example : at 9:00 - 9:15 - 9:30 - 9:45 - 10:00 -10:15 .. and so on..

Please guide and share the code if you already have it.


Thanks,

Rocky

 

Hi Rocky,


You can use TimeCurrent()with TimeMinute()modulo logic to trigger actions exactly at 15-minute marks like 9:00, 9:15, 9:30, etc.
If you need sample code, I can help you set it up.

 
TheRock007:


There is many online forums where you are invited to ask requests like this, however, this is not one of those. I recommend that you search codebase and modify one of those to suite your requirements, OR go to the Freelance page and make a request there and you will get it for a fee.

This forum is mostly for help with coding, unless it is AI or ChatGPT code; but you need to post your coding attempt first if you want to get help; otherwise you will likely not get any more responses.

 
Michael Charles Schefe #:

There is many online forums where you are invited to ask requests like this, however, this is not one of those. I recommend that you search codebase and modify one of those to suite your requirements, OR go to the Freelance page and make a request there and you will get it for a fee.

This forum is mostly for help with coding, unless it is AI or ChatGPT code; but you need to post your coding attempt first if you want to get help; otherwise you will likely not get any more responses.

Appreciate your feedback sir, 

I have posted my current code ..

 
Arsalan Riaz #:

Hi Rocky,


You can use TimeCurrent()with TimeMinute()modulo logic to trigger actions exactly at 15-minute marks like 9:00, 9:15, 9:30, etc.
If you need sample code, I can help you set it up.

Thanks Arsalan, My current code looks like this ..

 int timerminutes = 15;
 MqlDateTime today;


int OnInit()
  {
      DrawT();
      OnStartLoad();
      TimeLocal(today);

                EventSetTimer(timerminutes*60);
} 

But it runs randomly. not at 00:15 , 00:30 minutes.
Where should I put a condition?

Thanks,
 
TheRock007 #But it runs randomly. not at 00:15 , 00:30 minutes.
  1. Improperly formatted post. Please use the CODE button (Alt-S) when inserting code — https://www.mql5.com/en/articles/24#insert-code or attach the file. This time I fixed it for you.

  2. If you want to run on the first tick, use the M15 chart, drop the timer idea.

  3. Of course, it runs randomly; you started it randomly. Run every second and wait for a quarter-hour.

    int OnInit(){
       ⋮
       EventSetTimer(1);
       return INIT_SUCCEEDED;
    }
    void OnTimer(){
       ⋮
       static datetime lastRun=0;
       datetime now=TimeCurrent(), prevRun=lastRun; lastRun = now - now % (15*60);
       if(lastRun != prevRun) do_whatever();
       }
    }
 
William Roeder #:
  1. Improperly formatted post. Please use the CODE button (Alt-S) when inserting code — https://www.mql5.com/en/articles/24#insert-code or attach the file. This time I fixed it for you.

  2. If you want to run on the first tick, use the M15 chart, drop the timer idea.

  3. Of course, it runs randomly; you started it randomly. Run every second and wait for a quarter-hour.

That's exactly what I needed.

Thank you so much, William.