How to run a script automatically every hour?

 

Hello, 


I have a script that make screenshots for me. Now I need I do it with a shortkey. I use the screenshots for my excel sheet. Is there any possibility to run a script every hour?


In the attached file you will the script

Files:
 
Martijn Rikkert:

Hello, 


I have a script that make screenshots for me. Now I need I do it with a shortkey. I use the screenshots for my excel sheet. Is there any possibility to run a script every hour?


In the attached file you will the script

You can drop it on a chart and sleep for an hour inside of an infinite loop...

#property strict
#include <charts/chart.mqh>
#include <stdlib.mqh>

#define HOUR_MS (60 * 60 * 1000)

void OnStart()
{
   CChart chart;
   while (!IsStopped()) {
      for (long cid=ChartFirst(); cid>=0 && !IsStopped(); cid=ChartNext(cid)) {   
         chart.Attach(cid);
         string timeframe = EnumToString((ENUM_TIMEFRAMES)chart.Period());
         string file_name = StringFormat("%I64d-%s.png", cid, timeframe);
         if (!chart.ScreenShot(file_name, chart.WidthInPixels(), chart.HeightInPixels(0))) {
            Print(ErrorDescription(GetLastError()));
         }
         chart.Detach();
      }
      Sleep(HOUR_MS);
   }
}
 
Martijn Rikkert:

Hello, 


I have a script that make screenshots for me. Now I need I do it with a shortkey. I use the screenshots for my excel sheet. Is there any possibility to run a script every hour?


In the attached file you will the script

Better create an indicator

 
nicholi shen:

You can drop it on a chart and sleep for an hour inside of an infinite loop...

is this the complete code? 

 
Martijn Rikkert:

is this the complete code? 

So what is the code to make this work? I tried it in the code but I get errors. 

 
Martijn Rikkert:

So what is the code to make this work? I tried it in the code but I get errors. 

works for me
Reason: