Reply

Play a custom audio file in Signal Indicator

5 replies

TJ#

Customer, bbp_participant, community, 144 replies.

Visit profile

9 years ago #112772

hi Admin,

 

Under the signal indicator. How can I play a custom audio file?

 

Such as, PlaySound(“Starwars.wav”) while the default is PlaySound(“alert.wav”). 

 

regards,

 

TJ

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127291

Hello,

 

unfortunately signal indicators in EA Wizard only draw signals on chart, they don’t perform  custom actions that you specified in THEN section.

But you can combine it with an EA – have the same signal indicator exported as an EA that will play sound and then as signal indicator that will display the dots.

 

Yes,you should use file name of audio file in PlaySound function.According to MT4 help sound file should be located in terminal_directory\Sounds

Mark
StrategyQuant architect

0

TJ#

Customer, bbp_participant, community, 144 replies.

Visit profile

9 years ago #127314

hi Mark,

 

I tried the Starwars.wav as a price alert, it works perfectly but when I try to used it in EA Wizard (signal indicator) it will not play the Starwars.wav but played the default tone (alert.wav). Is there a bug somewhere in my version? 

 

Audio file is stored under, 

C:\Program Files (x86)\OANDA MT4\Sounds

 

Regards,

 

TJ

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127371

this is because in signal indicator mode it doesn’t use THEN actions at all, it uses Alert() function of MT4 and this is accompanied by the default sound.

 

You’d have to edit the signal indicator code – find where Alert() is used and put there your sound playing function.

Mark
StrategyQuant architect

0

TJ#

Customer, bbp_participant, community, 144 replies.

Visit profile

9 years ago #127657

Dear Mark,
 

I am not a programmer hence not sure what and where to look for the alert but I have trigger the search function and highlighted all the word “alert” and below are the sections that has the word “alert”, so which liner should I change to play the “starwars.wav” file? 

 

Thank you very much. 🙂 




 
extern bool    MT4Alert = true;
extern bool    EmailAlert = true;
extern string  EmailSubject = “Signal Alert : “;
extern int     LookBackForAlerts = 5;


 
void processSignal(int signalIndex, int i) {
   if(getSignal(signalIndex, i)) {
      drawSignal(signalIndex, i, getDrawOffset(signalIndex, i));
 
      bool previousSignal = getSignal(signalIndex, i+1);
      if(previousSignal == false && i<=LookBackForAlerts && (lastSignalDisplayed == 0 || lastSignalDisplayed < Time[i])) {
         // send alerts
         lastSignalDisplayed = Time[i];
 
         string alertText = getAlertText(signalIndex, i);
 
         if(MT4Alert) {
            Alert(alertText);
         }
         if(EmailAlert) {
            SendMail(StringConcatenate(EmailSubject, “Ind_M1_V4”), alertText);
         }
      }
   } else {
      drawSignal(signalIndex, i, 0);
   }
}
 
//+——————————————————————+
 
string getAlertText(int signalIndex, int i) {
   string text = Symbol() +”/” + getPeriodAsString() + ” – ” + TimeToStr(Time[i]);
   text = StringConcatenate(text, ” Signal Alert :”);
 
if(signalIndex == 1) {
      text = StringConcatenate(text, ” Long (#1, Unknown) : “);
      text = StringConcatenate(text, Signal1Text);
   }
if(signalIndex == 2) {
      text = StringConcatenate(text, ” Short (#2, Unknown) : “);
      text = StringConcatenate(text, Signal2Text);
   }
 
   return(text);



 

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #127908

ok, you can edit the code and add the code to play sound into this block:

 

if(MT4Alert) {
   Alert(alertText);
   
PlaySound(“Starwars.wav”); // added

}

 

 

I’m not sure if it would work, because I’m not sure if MT4 allows indicators to play sounds, but probably yes.

Mark
StrategyQuant architect

0

Viewing 5 replies - 1 through 5 (of 5 total)