Add in a time delay to customer indicator

 

I have this custom indicator that creates an alert / push notification when CCI crosses either -100 or 100. 

The problem is it keeps going off every time it bounces around the 100 mark...very annoying.

I wanted to try and add a delay something like this to the attached indicator:

bool AlertDelay() {
   static datetime last_time;
   if (TimeCurrent()-last_time<30) {    // delay for 30 seconds
      return(false);
   } else {
      last_time=TimeCurrent();
      return(true);
   }
}

And then simply check AlertDelay()'s return before using Alert() like so:

if (AlertDelay()) Alert("Whatever...");

 

Will that work?  How do I add it to this indicator?

Files:
Reason: