Delay in playing next sound alert

 

Thanks to raff1410@o2.pl for this great alert indicator.

How would one add a delay to playing the sound alert? The sound file loops very quickly and can sound annoying..


#property copyright "raff1410@o2.pl"

#property indicator_chart_window
extern string LineName="MyLineL";
extern string LineName1="MyLineH";
extern color LineColor=Pink; 
extern color LineColor1=DodgerBlue; 
extern int LineStyle=STYLE_SOLID;
extern int LineStyle1=STYLE_SOLID;
extern int pipDistance = 5;
extern string AlertWav="alert.wav";




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {


      ObjectCreate(LineName, OBJ_HLINE, 0, 0, Bid - pipDistance*Point);
      ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
      ObjectSet(LineName, OBJPROP_COLOR, LineColor);
      
      ObjectCreate(LineName1, OBJ_HLINE, 0, 0, Bid + pipDistance*Point);
      ObjectSet(LineName1, OBJPROP_STYLE, LineStyle1);
      ObjectSet(LineName1, OBJPROP_COLOR, LineColor1);
      
     


        
      double val =  ObjectGet( LineName, OBJPROP_PRICE1);
      if (Bid <= val ) PlaySound(AlertWav);
      
 
      
      double val1 =  ObjectGet( LineName1, OBJPROP_PRICE1);
      if (Bid >= val1 ) PlaySound(AlertWav);




else



//----
//----
   return(0);
  }
//+------------------------------------------------------------------+ 
 
if (Bid >= val1 ) PlaySound(AlertWav);

You are looking at a signal. Act on a change of signal.
          MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 (2017)