Making a wav file repeat in an indicator

 

Could anyone please help me with this? I'm trying to play a wav file multiple times when an alert is triggered. With the code below I finally got it to play but only once. For some reason the sleep and while loop they're in don't do what I would expect.


if ((DoAlarm) && (AlertTrig) && (TimeOK))
{
Alert(Symbol()+" - "+ctf+"--Trend Alert");
AlertTrig = false;
Sounder = true;
}

if (Sounder)
{
while (AlertRepeat > 0)
{
PlaySound("toads.wav");// holler it out2
Sleep(7000);
AlertRepeat--;
}
Sounder = false;
}


Many thanks.

 

Hi

How long does it take the system to complete your sound wave? I have found if you start a wave before another is finished the second one is ignored. I have never been absolutely sure if MQ4 works correctly with multiple wave calls. You could just splice the repeats in to one wave file that would do the same job.

 
Ruptor:

Hi

How long does it take the system to complete your sound wave? I have found if you start a wave before another is finished the second one is ignored. I have never been absolutely sure if MQ4 works correctly with multiple wave calls. You could just splice the repeats in to one wave file that would do the same job.


Thanks Ruptor--

You're right--I made this as a script and when dragged onto the chart, works perfectly--the sleep cycle is about twice as long as the wav file. What you say also got me to thinking that may also be why often the alert "ding" is heard but the wav file is not--that's why I broke it into two routines.


What I want this thing to do is to show the alert and then play a wav file for the number of times set in the input--currently 3 times--as an audible alarm that can be heard farther away than the chair in front of the screen.


Thanks again---any other thoughts are very welcome.

Reason: