Download MetaTrader 5

PlaySound and Alert

To add comments, please log in or register
Taylor
72
Taylor  
I'm trying to produce some alerting mechanisms in my EA and ran across some funny behavior. When I use the Alert function and the PlaySound function together, then the Alert function seems to supercede the PlaySound function, which doesn't kick off. So, as an example, if I have the following 3 functions all enabled:

Alert();
PlaySound();
SendMail();

The Alert and SendMail functions work, but not PlaySound. If I disable the Alert() function, then PlaySound works fine. It also works fine with MessageBox(), though, I prefer the Alert function.

1. Is there a way to get these functions to work together? I am referencing a different WAV file in PlaySound() then the one used by Alert().
2. Is there a way to get the Alert() function to use a different WAV file?
3. Is it possible to use an MP3 file with the PlaySound function?

Thanks.

stockwet
Taylor
72
Taylor  
Hello. I was just wondering whether this is an unanswerable question, or just a dumb question? I searched to see if it had already been asked, but, never found anything similar. Does anyone have ideas regarding the functionality of the Alert() vs PlaySound() and why they would, seemingly, conflict?
Caroline Carlin Arneodo
17
Caroline Carlin Arneodo  
Hello,

I am looking also for the same answer, but I have an idea about this, and it is that the commands are triggered too fast to allow both sounds to play in sequence. .. there should be some delay time to add for the playsound, like 10 seconds which seems to be the usual minimum as per the Alert tab in the terminal.

The only way to have a different file playing as "alert" would be to rename it to alert.wav as I'm afraid the code is set up like that.

Only *.wav files work with the Playsound, but anyway those would be short-time files so the *.wav length of file is not that heavy.

Have you tried Playsound twice instead? Just thought this could work, I am going to try it.

Hope it helps.

P.S. Thinking of it... both might work but won't activate the alert window :(

.
Caroline Carlin Arneodo
17
Caroline Carlin Arneodo  
stockwet:
2. Is there a way to get the Alert() function to use a different WAV file?

Thanks.

stockwet
Found this: 'Secrets of MetaTrader 4 Client Terminal: Alerting System'
Ahmad Waddah Attar
11170
Ahmad Waddah Attar  
try this method

Alert();
Sleep(500); // waiting a half second
PlaySound();
SendMail();
Caroline Carlin Arneodo
17
Caroline Carlin Arneodo  
Thank you very much, I will try it as soon as markets open :)
Rashid Umarov
Admin
12400
Rashid Umarov  
Use script and you no need waiting of markets opening.
Caroline Carlin Arneodo
17
Caroline Carlin Arneodo  
Thank you!

I read about the "sleep" function and it says it won't work in an indicator. .. is there any other way to place Alert and Playsound to play one after the other in an indicator?

Thanks in advance.
ma
239
ma  
Hi guys,

I am just unable to send an e-mail during int start (). Is there any thing I am missing? I thought that just this function call SendMail ("MT4 START", " Looking for HELP"+DoubleToStr(Ask,Digits)); would send me an e-mail, but....

Detail: if I use this call SendMail("MT4 START", " Looking for HELP"+DoubleToStr(Ask, Digits)); at int init(), I do receive an-email every time that my EA starts.

Thanks a lot.
ma
239
ma  
Ok,

Let me be clearer: If I look at this small program bellow, I would guess that I should receive two e-mails. However, I am receiving just one e-mail from the initialization part of the program. Moreover, the sound "alert.wav" doesn't play at all. So please, could someone help me here. Thank you a lot.

Cheers,

__________________________
int init()
{
PlaySound ("phone.wav");
SendMail("Init", "Yes Ok");
return(0);
}

int start()
{
PlaySound ("alert.wav");
SendMail("Start", "No Ok");
return (0);
}
__________________________
zap
181
zap  
brspMA:
Ok,

Let me be clearer: If I look at this small program bellow, I would guess that I should receive two e-mails. However, I am receiving just one e-mail from the initialization part of the program. Moreover, the sound "alert.wav" doesn't play at all. So please, could someone help me here. Thank you a lot.



Your whole program runs in about one millionth of a second, so probably phone.wav is still playing, when you want to play alert.wav and it seems the sounds are not cacheing. This is may be the same with the emails. Use it as an EA instead of script and wait for a new tick.
12
To add comments, please log in or register