Is there anyone who could help me add a sound alert to this mq4 indicator, please?

 

Hi,

I would like to add a sound alert to this mq4 indicator(it seems very simple to get it done but I am really not good at even the basic coding),

is there anyone who could help me, please?


thanks in advance!


yours,

shunfengcn

 
shunfengcnfx: Hi, I would like to add a sound alert to this mq4 indicator(it seems very simple to get it done but I am really not good at even the basic coding),

is there anyone who could help me, please?

https://www.mql5.com/en/articles/1448
Sound Alerts in Indicators
Sound Alerts in Indicators
  • 2007.05.03
  • Andrey Khatimlianskii
  • www.mql5.com
How to create "voice" indicators for daily usage.
 
shunfengcnfx: I would like to add a sound alert to this mq4 indicator(it seems very simple to get it done but I am really not good at even the basic coding),

is there anyone who could help me, please?

  1. When you post code please use the SRC button! Please edit your post.
               General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Help you with what? You haven't stated a problem.
    You have only four choices: We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
              No free help
              urgent help.
 
shunfengcnfx:

Hi,

I would like to add a sound alert to this mq4 indicator(it seems very simple to get it done but I am really not good at even the basic coding),
is there anyone who could help me, please?
thanks in advance!

yours,
shunfengcn

Hi,

Modify your indicator by inserting this code as example below :

1. Input parameter

//--new input
input bool alert_sound=true;//Sound Alert
input bool alert_screen=false;//Screen Alert

2. Buy :

void ArrowBuyCreate(string name, datetime time, double price)
  {
   ResetLastError();
   if(ObjectCreate(0,name,OBJ_ARROW_BUY,0,time,price))
    {
     ObjectSetInteger(0,name,OBJPROP_COLOR,clrDodgerBlue);
     ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
     ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
     ObjectSetInteger(0,name,OBJPROP_BACK,true);
     ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
     ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
     ObjectSetInteger(0,name,OBJPROP_ZORDER,0);
     //---new code--Sounds
     if(alert_sound) 
     { 
        PlaySound("Alert.wav");
        Print("!* Arrow Buy: ",name," has been created.");
     }
     //---new code--Screen
     if(alert_screen) Alert("!* Arrow Buy: "+name+" has been created.");

    }
  }

3. Sell

void ArrowSellCreate(string name, datetime time, double price)
  {
   ResetLastError();  
   if(ObjectCreate(0,name,OBJ_ARROW_SELL,0,time,price))
    {
     ObjectSetInteger(0,name,OBJPROP_COLOR,clrTomato);
     ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
     ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
     ObjectSetInteger(0,name,OBJPROP_BACK,true);
     ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
     ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
     ObjectSetInteger(0,name,OBJPROP_ZORDER,0);
     //---new code--Sounds
     if(alert_sound) 
     { 
        PlaySound("Alert.wav");
        Print("!* Arrow Sell: ",name," has been created.");
     }
     //---new code--Screen
     if(alert_screen) Alert("!* Arrow Sell: "+name+" has been created.");

    }
  }

And don't forget to use SRC button when posting the code.

Good luck,

Yo. (^̮^)

 

thanks!

yours,

shunfengcn

 
whroeder1:
  1. When you post code please use the SRC button! Please edit your post.
               General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Help you with what? You haven't stated a problem.
    You have only four choices: We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
              No free help
              urgent help.

thanks for your guide, and I am really not aware of the rules for the forum.

I've edited the code with SRC button.

yours,

shunfengcn

 
Yohana Parmi:

Hi,

Modify your indicator by inserting this code as example below :

1. Input parameter

2. Buy :

3. Sell

And don't forget to use SRC button when posting the code.

Good luck,

Yo. (^̮^)


Thanks a lot for your help, Yohana!

I've added the code for the alert into the original one.

I will try it and see if it works later.

yours,

shunfengcn 

Reason: