Indictor sound alert to match currency pair

 

I have an indictor that gives a sound alert when the price moves a certain amount, adapted from - https://www.mql5.com/en/code/14388.

For each currency pair it gives a different sound alert, see extract below.

if(TimeCurrent()-lasttime>=TimeDeley && range>int(BarPoint))
        {
                if(Symbol()=="AUDCAD")
                {
                PlaySound("AUDCAD.wav");
                lasttime=TimeCurrent();
                }
                if(Symbol()=="AUDCHF")
                {
                PlaySound("AUDCHF.wav");
                lasttime=TimeCurrent();
                }

This current solution takes up 300 lines of code for all the currency pairs my broker deals with.

I thought an easier solution would be to match the file name with the current chart's symbol, such as the following (which obviously doesn't work):

if(TimeCurrent()-lasttime>=TimeDeley && range>int(BarPoint))
{
PlaySound("Symbol().wav");
lasttime=TimeCurrent();
}

Does anyone have any idea on how to make the above work, or another solution to this?

Thank you.

BigBarSound
BigBarSound
  • votes: 14
  • 2016.01.20
  • Nikolay Kositsin
  • www.mql5.com
The BigBarSound indicator plays sound alerts when candlestick body size exceeds a certain value.
 

It's very easy. Try following code.

if(TimeCurrent()-lasttime>=TimeDeley && range>int(BarPoint))
  {
      //PlaySound("Symbol().wav");
      string wavefile = StringSubstr(Symbol(),0,6) + ".wav";
      PlaySound(wavefile);
      lasttime=TimeCurrent();
  }
 
Naguisa Unada:

It's very easy. Try following code.


Thank you very much for your help, it works.

Reason: