Download MetaTrader 5
To add comments, please log in or register
Articles have already helped many traders. Come and read them!
kok keong Chat
7
kok keong Chat 2015.09.09 23:41 

Hi Community,

I need help on how to code the "playsound" multiple time. (ie 10 times repeating) once the condition met. Below are the original coding.

 

void SendAlert(string dir)

{

   string per = TimeframeToString(Period());

   if (UseAlerts)

      {

      Alert(dir + " Pinbar on ", Symbol(), " @ ", per);

      PlaySound("alert.wav"); 

 

 Thanks and appreciate for your kind advise and helping hand. I am new to coding. Instead of playing the sound once, I would like it to play a number of times to alert me.

 

best regards 

kk 

Keith Watford
Moderator
7947
Keith Watford 2015.09.10 00:09  

I haven't done much with OnTimer, but I guess that you could do it

   if(condition) 
     {
      EventSetTimer(2);
     }

 when you need to send alerts in your main code

then

void OnTimer()
  {
   static int count=0;
   if(count<10)
     {
      PlaySound("alert.wav");
      count++;
     }
   if(count>=10)
     {
      count=0;
      EventKillTimer();
     }

  }

 so actually kill the timer within its own function.

Obviously you may not be able to do this if you use OnTimer in the code for something else 

/
To add comments, please log in or register