Help with Playsound()
Posted: Oct 17 2006
I have a 200 period moving average on 2401 volume bar chart.
I would like to add a sound signal when the price cross the MA line.
I have added a playsound() statement to the code.
It plays the sound signal alright. The problem is, it plays the sound multiple times (on every tick), until another new bar is created. This happens even if I turn off the "Update on every tick" box.
What can I do to make it play the sound only once per bar?
here's the code:
inputs:
Price( Close ),
Length( 50 ) ;
variables:
Avg( 0 ) ;
Avg = AverageFC( Price, Length ) ;
Plot1[1]( Avg, "Avg" ) ;
{ Alert criteria }
if Price > Avg and Avg > Avg[1] and Avg[1] <= Avg[2] then
PlaySound("c:/soundfiles/alarm.wav")
else if Price < Avg and Avg < Avg[1] and Avg[1] >= Avg[2] then
PlaySound("c:/soundfiles/alarm.wav");
I would like to add a sound signal when the price cross the MA line.
I have added a playsound() statement to the code.
It plays the sound signal alright. The problem is, it plays the sound multiple times (on every tick), until another new bar is created. This happens even if I turn off the "Update on every tick" box.
What can I do to make it play the sound only once per bar?
here's the code:
inputs:
Price( Close ),
Length( 50 ) ;
variables:
Avg( 0 ) ;
Avg = AverageFC( Price, Length ) ;
Plot1[1]( Avg, "Avg" ) ;
{ Alert criteria }
if Price > Avg and Avg > Avg[1] and Avg[1] <= Avg[2] then
PlaySound("c:/soundfiles/alarm.wav")
else if Price < Avg and Avg < Avg[1] and Avg[1] >= Avg[2] then
PlaySound("c:/soundfiles/alarm.wav");