Hi,
I want my indicator to play a series of sounds, not just one. For that, I initially tested calling 3 PlaySound() one after the other hoping that the second would only start playing after the first was finished and the same for the third.
Unfortunately I was wrong: in such conditions, even though both of my first two calls to PlaySound return "true", only the third call is effective and the sound is played. It would seem a call to this function immediately stops any previous call.
So how can I do what I want? How can I make the second PlaySound (or other function) only start after the end of the first one? Or, in general, how can I play a sequence of sounds from within a MQL5 Indicator?
Hello
You can use 3 sets of different indicators or use one particular indicator 3 times. but since theyll play all the same time youll hear only one sound.
Here also there is another option. IDK why youd like to hear a sequential sound set but you also can make a costume sound, attaching all 3 files together and choose the indicator to play that sound file.
Hello
You can use 3 sets of different indicators or use one particular indicator 3 times. but since theyll play all the same time youll hear only one sound.
Here also there is another option. IDK why youd like to hear a sequential sound set but you also can make a costume sound, attaching all 3 files together and choose the indicator to play that sound file.
Hmm all these options are unnacceptable for my purposes. How can I ask Metaquotes to change their PlaySound system to put the option of blocking the code until the sound is finished playing?
Hmm all these options are unnacceptable for my purposes. How can I ask Metaquotes to change their PlaySound system to put the option of blocking the code until the sound is finished playing?
Here's another way (this example will play 3 different sounds at the start of every new bar):
int playSound = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { EventSetTimer(1); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { ArraySetAsSeries(time,true); static datetime lastBarTime = 0; if (time[0]!=lastBarTime) { playSound = 3; lastBarTime = time[0]; } return(rates_total); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { switch(playSound) { case (3): PlaySound("Alert"); break; case (2): PlaySound("Connect"); break; case (1): PlaySound("Email"); break; } playSound--; }
Edit: Oops... you need to add the highlighted line for this example to work repeatedly...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want my indicator to play a series of sounds, not just one. For that, I initially tested calling 3 PlaySound() one after the other hoping that the second would only start playing after the first was finished and the same for the third.
Unfortunately I was wrong: in such conditions, even though both of my first two calls to PlaySound return "true", only the third call is effective and the sound is played. It would seem a call to this function immediately stops any previous call.
So how can I do what I want? How can I make the second PlaySound (or other function) only start after the end of the first one? Or, in general, how can I play a sequence of sounds from within a MQL5 Indicator?