MQL4 - automated forex trading   /  

Forum

PlaySound and Alert

Back to topics list  | 1 2 To post a new topic, please log in or register

avatar
18
stockwet 2006.08.21 21:13 
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
Comparative Analysis of 30 Indicators and Oscillators

Comparative Analysis of 30 Indicators and Oscillators

The article describes an Expert Advisor that allows conducting the comparative analysis of 30 indicators and oscillators aiming at the formation of an effective package of indexes for trading.


avatar
18
stockwet 2006.08.29 23:18 
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?

avatar
10
doblece 2007.02.01 05:18 
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 :(

.

avatar
10
doblece 2007.02.01 05:34 
stockwet wrote:
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'


avatar
1890
waddahattar 2007.02.06 08:53 
try this method

Alert();
Sleep(500); // waiting a half second
PlaySound();
SendMail();



avatar
10
doblece 2007.03.03 13:36 
Thank you very much, I will try it as soon as markets open :)

avatar
Moderator
33759
Rosh 2007.03.03 15:12 
Use script and you no need waiting of markets opening.

avatar
10
doblece 2007.03.03 19:17 
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.

avatar
87
brspMA 2007.07.25 02:33 
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.

avatar
87
brspMA 2007.07.25 23:22 
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);
}
__________________________

avatar
125
Zap 2007.07.26 01:00 
brspMA wrote:
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.
Back to topics list   | 1 2  

To add comments, please log in or register