Intermittent PlaySound

 

Does anyone know how to "force" PlaySound to complete playing its wave file even though there are ticks occuring before the wav file completes? I noticed that every time a tick occurs, the PlaySound function does not complete the wav file and starts over. Very annoying. Here is a sample of the code:

   //market conditions are right
   //trade_ready = 1;
   //currency_pair = "EURUSD";
  
    if (trade_ready == 1 && currency_pair == "EURUSD")
      {
       PlaySound ("eur dollar");
      }
 
Maybe you should only play the sound once rather than repeating it for each tick ?
 
RaptorUK:
Maybe you should only play the sound once rather than repeating it for each tick ?


Can't do this. The purpose of the indicator is to alert me when certain market conditions occur. Often I am away from the computer or I might be asleep and I need my computer to alert me that a potential trade set-up is occuring. I can run this indicator on many currency charts simultaneously, and it will immediately tell me which currency pair is ready for a trade. It helps me to zero in on the pair quickly, especially when I have about 10 charts up.

The indicator works fine, but the sounds are sporadic because of the tick issue. Any way I can get around this and force the ea to ignore the next tick before it completes the wav?

 
forestmyopia:

Any way I can get around this and force the ea to ignore the next tick before it completes the wav?

Yes, use a variable to store the time when the WAV is first played . . . next time is is going to be played only do it if enough time has elapsed since the last time it was played for it to have played completely . . . if enough time has elapsed play it again Sam . . :-)
 
RaptorUK:
Yes, use a variable to store the time when the WAV is first played . . . next time is is going to be played only do it if enough time has elapsed since the last time it was played for it to have played completely . . . if enough time has elapsed play it again Sam . . :-)

Ok. I will try this approach. Thanks for the suggestion.
Reason: