Alert never ends and freezes MT5

To add comments, please log in or register
traderz
21
traderz  

What is wrong with this alert? That sound never ends and finally it freezes MT5.


        manageAlerts(time[rates_total-1],rates_total);

            return(rates_total);
           }

         //+------------------------------------------------------------------+
         void manageAlerts(datetime currTime,int bars)
           {
            if(alertsOn)
              {
               datetime time = currTime;
               int whichBar = 0; if(!alertsOnCurrent) whichBar = 1;
               static string  previousAlert1="nothing";
               static datetime previousTime1=0;
               if(Up[whichBar]!=EMPTY_VALUE) doAlert(previousTime1,previousAlert1,time,"trend changed to up");
               if(Dn[whichBar]!=EMPTY_VALUE) doAlert(previousTime1,previousAlert1,time,"trend changed to down");
              }
           }

         //+------------------------------------------------------------------+
         //|                                                                  |
         //+------------------------------------------------------------------+
         void doAlert(datetime &previousTime,string &previousAlert,datetime forTime,string doWhat)
           {
            string message;

            if(previousAlert!= doWhat || previousTime!=forTime)
              {
               previousAlert  = doWhat;
               previousTime   = forTime;
               message=TimeToString(TimeLocal(),TIME_SECONDS)+" "+_Symbol+" Brain trend signal "+doWhat;
               if(alertsMessage) Alert(message);
               if(alertsEmail) SendMail(_Symbol+" Brain trend",message);
               if(alertsSound) PlaySound("alert2.wav");
              }
           }
To add comments, please log in or register