Interupt Timer

 
Does MT have an Interupt Timer, eg: in a customer indicator, I wish to do something exactly once every 5 minutes, NOT depends on the price tick.

Or does anyone know how to realise this function?

In script, it can be done by using Sleep() function, but the time of each cycle is not exactly the time specified in Sleep() function, because the computation time for running the whole script is unkown.

Hence, I think it is a quite useful ideal for MT to introduce the concept of interupt.
 
You can adjust sleep time by estimating the script running time:
 
int notch = GetTickCount();
 
// A lot of computation here;
tmp = a;
a = b;
b = tmp;
 
notch = GetTickCount() - notch; // get computation time
 
Sleep(5 * 1000 * 60 - notch); // Sleep for the rest of the timeout.
 
Alert("bingo!");

Regards,

mqlexpert <at> gmail <dot> com
 
Hi, thank you for your response.

If the Sleep() funciton is used, then during the 'sleeping' period, the programme can not do anything.

What I am tring to achive is a customer indicator, process real-time data, and periodically, say every 5 minutes, take a screen shot, update FTP, send an email etc.

It can be done quite easily in Script, but I am just wondering whether it is possible in customer indicator.

Cheers.
 
sure, i think i know what you mean... use the gettickcount that Irtron used, 1000 of them is one second, so use 300000 for 5 min (is that right? 60 -1000's in a min *5min, yep 300 seconds is 300,000ms).. do your screen shot, etc, then reset the var that is holding the time. probably needs to be a global..
Sleep() does not work in an indicator anyway.
 
Thank you for your help.

That certainly gives me some idea.

But still can not solve the problem entirely. Because if there is no new price quotes in 5 minutes, then the customer indicator will not be executed, i.e., this method can not guarantee doing something exactly every 5 minutes in customer indicator.

Cheers.
 
2607 wrote:
Thank you for your help.

That certainly gives me some idea.

But still can not solve the problem entirely. Because if there is no new price quotes in 5 minutes, then the customer indicator will not be executed, i.e., this method can not guarantee doing something exactly every 5 minutes in customer indicator.

Cheers.

Hi,
Your question is very important - I think for lot of people who are working with MT4.
Helped you anyone - because i'm solving the same problem.....
my email is art.graph@zmail.sk

Art
 
if there is no tick in 5 minutes (which rarely happens) then nothing has changed and you will have nothing new to send to your customer (like screenshot, it still will be the same as 5 minutes ago).
Reason: