Add in a time delay to customer indicator

Back to topics list To post a new topic, please log in or register
avatar
4
bearwa77 2015.02.13 02:06
 

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?

Attached files:
  cciwithalert.mq4  (3.68 KB)
Back to topics list  

To add comments, please log in or register