How to change the alerts to the selected timeframe?

 

Hello, 

I have an indicator,it is very helpfull, but if creates alerts all the time. And this is spamming my mailbox. I want only alerts on the selected timeframes. So when I have the indicator on a 4 H chart then it should create an alerts every 4 hours etc.. 

Can anybody help me with this? I tried to do it myself, but I am not a good coder. 

Files:
 
Anyone???
 

You shouldn't be so impatient. Your 2nd post will put some people off trying to help you.

   bool newBar=false;
   static datetime barTime=0;
   datetime thisBarTime=Time[0];
   if(barTime!=thisBarTime)
     {
      barTime=thisBarTime;
      newBar=true;
     }

//various approaches from here....
//one being
   
   if(newBar)
     {
      //Do Alert Check
     }