AudioPriceAlert

hayseed

Master Trader
Jul 27, 2010
555
157
109
usa
//------

hey maverick..... it would be best to hard code in the wavs and not have a drop down box in this case..... it's just going to complicate matters...... below is a working example of the code needed for wav selection......h

//-------

MQL4:
enum wavs
  {
   a=0,     // alert.wav
   b=1,     // alert2.wav
   c=2,     // connect.wav
   d=3,     // disconect.wav
   e=4,    //  ok.wav
   f=5,    //  stops.wav
   g=6,    //  news.wav
  };
//--- input parameters
input wavs wav=a;
 
string wavarray[7] = {"alert.wav","alert2.wav","connect.wav","disconnect.wav"  }; // and so on
 
 
int init()
{
return(0);
}
//------
int start()
  {
//---
 
if(Ask > 1.0) { PlaySound(wavarray[wav]);} 
//---
   return(0);
  }
//+------------------------------------------------------------------+
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Very sorry but I just can't see how your proposed code works with what I have got already :(
MQL4:
//----
    if ((Ask > PriceAbove_1) && (PriceAbove_1 > 0))
    {
       Alert("Price above the alert level 1.");
       PlaySound("alert.wav");
       SendMail("Price for " + Symbol() +  " above the alert level 1 " + Ask, "Price for " + Symbol() +  " reached " + Ask + " level, which is above your alert level of 1 " + PriceAbove_1);
       ObjectDelete("PriceAbove_1");
       PriceAbove_1= 0;
    }
//----

If we have to
hard code in the wavs
then surely I can do that already - or are you suggesting a short cut menu of all the available sounds

.
 

hayseed

Master Trader
Jul 27, 2010
555
157
109
usa
Very sorry but I just can't see how your proposed code works with what I have got already :(

.
//----

hey maverick..... i am not sure what you already have..... looking at your code above, using playsound() and alert() together will be difficult..... use one or the other.....

below is an example of drop down menus .... start with just 1 line..... get that working perfectly..... then add another if needed..... keep it simple at first......h

//-----
 

Attachments

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Not really sure why I referred to that OLD code above - supposed to have moved on from there :(
i am not sure what you already have
The way I see it . . .

I need to add - underneath
MQL4:
#property indicator_chart_window
MQL4:
extern double PriceAbove_5 = 0.0;
extern double PriceAbove_4 = 0.0;
extern double PriceAbove_3 = 0.0;
extern double PriceAbove_2 = 0.0;
extern double PriceAbove_1 = 0.0;
extern double PriceExact_0 = 0.0;
extern double PriceBelow_1 = 0.0;
extern double PriceBelow_2 = 0.0;
extern double PriceBelow_3 = 0.0;
extern double PriceBelow_4 = 0.0;
extern double PriceBelow_5 = 0.0;
 
enum wavs
  {
   a=0,     // alert.wav
   b=1,     // alert2.wav
   c=2,     // connect.wav
   d=3,     // disconect.wav
   e=4,     // ok.wav
   f=5,     // stops.wav
   g=6,     // news.wav
  };
//+------------------------------------+
// | input parameters                        |
//+------------------------------------+
input wavs PriceAbove_5_wav1 = a;  
input wavs PriceAbove_4_wav1 = a;
input wavs PriceAbove_3_wav1 = a;
input wavs PriceAbove_2_wav1 = a;  
input wavs PriceAbove_1_wav1 = a;
input wavs PriceExact_0_wav1 = a;
input wavs PriceBelow_1_wav1 = a;
input wavs PriceBelow_2_wav1 = a;
input wavs PriceBelow_3_wav1 = a;
input wavs PriceBelow_4_wav1 = a;
input wavs PriceBelow_5_wav1 = a;
 
string wavarray[7] = {"alert.wav","alert2.wav","connect.wav","disconnect.wav"  }; // list your wav choices in an array like this

Then change
MQL4:
PlaySound("alert.wav");
For
MQL4:
 PlaySound(wavarray[PriceAbove_1_wav1]);

Not really sure what the letters a, b ,c, d, e, f, g ... are all about

.
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Realise I am trying to run before I can walk ... but I am already thinking ahead ... how to get this to work
MQL4:
//----
 
  #property PriceAbove_5_color5        Lime
  #property PriceAbove_4_color4        Lime
  #property PriceAbove_3_color3        Lime
  #property PriceAbove_2_color2        Lime
  #property PriceAbove_1_color1        Lime
  #property PriceExact_0_color0        Blue
  #property PriceBelow_1_color1        Red
  #property PriceBelow_2_color2        Red
  #property PriceBelow_3_color3        Red
  #property PriceBelow_4_color4        Red
  #property PriceBelow_5_color5        Red
 
  #property PriceAbove_5_width5        0
  #property PriceAbove_4_width4        0
  #property PriceAbove_3_width3        0
  #property PriceAbove_2_width2        0
  #property PriceAbove_1_width1        0
  #property PriceExact_0_width0        0
  #property PriceBelow_1_width1        0
  #property PriceBelow_2_width2        0
  #property PriceBelow_3_width3        0
  #property PriceBelow_4_width4        0
  #property PriceBelow_5_width5        0
 
  #property PriceAbove_5_style5        DOT
  #property PriceAbove_4_style4        DOT
  #property PriceAbove_3_style3        DOT
  #property PriceAbove_2_style2        DOT
  #property PriceAbove_1_style1        DOT
  #property PriceExact_0_style0        SOLID
  #property PriceBelow_1_style1        DASH
  #property PriceBelow_2_style2        DASH
  #property PriceBelow_3_style3        DASH
  #property PriceBelow_4_style4        DASH
  #property PriceBelow_5_style5        DASH
 
//----

The problem for me which is more of a difficulty than a problem is that my MT4 is running in a VM inside my main computer meaning that it's not just a case of "suck it and see" what happens ...

H'mmm ... got me thinking about a second VM just for testing ... maybe ;)

.
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Well, a few hours later and I now have my second VM up and running :) which I will devote to road testing and tweaking mq4 code. The secret as far as I am concerned is to have another copy of DropBox installed for moving stuff about ;)

Sublime text editor is on my Linux Mint and was pleased to be able to get a copy of the same to run on my Win 7 VM

Have I been wasting my time . . . time will tell
.
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Wondering how to get a 3rd column in inputs for the wav file options

Sound_zpshgbjt6tn.png

.
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Thing is, could I make the beep, ring or whatever play more than once - for me it's about whats going on without having to keep focusing on the chart - Hear one beep ... no problem Hear five beeps ... better have a look OR if the other way money in the bank :)

I did actually create some different length wav files with Audacity like ring-ring-ring-ring-ring - But you said to keep them short

H'mmm ... what's the difference between ring-ring-ring-ring-ring AND ring * 5
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Well pleased with myself :) ... Eventually spotted 3 Warnings which turned out to be a case of me using Lower instead of Upper case letters :(

WavTest_zpsohzhzl3u.png


I will having now seen the layout change the order to PriceAbove on top of PriceAbove_wav

The question is though ... How do I now add the lines ... Colour - Size & Style

On the previous PriceAudioAlert_v3.0 I had to access the mq4 code to change the lines

How do I get control in Inputs ?
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Thought I had cracked it and was looking good

HOUSTON WE HAVE A PROBLEM

Soon as I click Close I lose most of my lines

WavTest_1_zpsdkzfeben.png


Strange ... if there is a problem then why not all the lines ?

Sorry to put this on you BUT i have absolutely no idea what I am looking for

Appreciate your time ... thank you :)

Haven't been able to test the wav files with the markets closed - No reason why there should be a problem - fingers crossed
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
If i read you right ... there is a point where too many many Inputs would confuse the indicator ... hence you leaving out line styles

What about using Colors ?

Lines_zpsldxhf26v.png


Granted I haven't got a clue what's involved ... but it looks good on paper ;)
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
Might be onto something ... The remaining two lines are ABOVE price ... price hasn't reached them yet ... once price reaches them then they to will be deleted.

So why, when the chart is not live ... what about the Exact and Below lines ?
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
The reason why these last posts look one sided ... No hayseed ... I have just copied MY edited side from our PM (private messaging) Decided to use PM for the FULL code rather than confuse you guys ... nothing personal :)

Hopefully hayseed will pick up from here ... I left him a memo
 

hayseed

Master Trader
Jul 27, 2010
555
157
109
usa
I left him a memo
//-----

hey maverick...... there could be several reasons why the lines disappeared..... remember, spreads are fictitiously wide on weekends so put the ask line on the chart to assure your lines are outside it.......

to test your wav file and lines while the market is closed, apply your indicator to a chart making sure the lines are outside the spread..... then drag one line past the point where it should alarm...... then click ctrl and i at the same time..... this brings up the indicators on that chart.... just x out of that..... the line should vanish and playsound should sound off the correct wav file.......

below is partial but working code..... expand as needed..... but don't forget, a couple traffic lights are ok..... a hundred is a traffic jam......h
//-----

MQL4:
#property version   "1.00"
 
 
#property strict
#property indicator_chart_window
//--------
 
 
enum wavs
   {
    a=0,     // alert.wav
    b=1,     // alert2.wav
    c=2,     // connect.wav
    d=3,     // disconect.wav
    e=4,     // ok.wav
    f=5,     // stops.wav
    g=6,     // news.wav
   };
 
 
 
//--- input parameters
 
input wavs   PriceAbove_3_wav  = c;
extern double PriceAbove_3      = 0.0;
extern int    PriceAbove_3size  = 5;
extern color  PriceAbove_3clr   = Blue;
 
input wavs   PriceAbove_2_wav  = b;
extern double PriceAbove_2      = 0.0;
extern int    PriceAbove_2size  = 2;
extern color  PriceAbove_2clr   = Lime;
 
input wavs   PriceAbove_1_wav  = a;
extern double PriceAbove_1      = 0.0;
extern int    PriceAbove_1size  = 3;
extern color  PriceAbove_1clr   = Red;
 
extern bool SendEmail = false; //If true e-mail is sent to the e-mail address set in your MT4. E-mail SMTP Server settings should also be configured in your MT4  
 
string wavarray[7] = {"alert.wav","alert2.wav","connect.wav","disconnect.wav"  }; // list your wav choices in an array like this
 
 
int init()
{
 
//----
      if (PriceAbove_3 > 0)
      {
         ObjectCreate("PriceAbove_3", OBJ_HLINE, 0, Time[0], PriceAbove_3);
         ObjectSet("PriceAbove_3", OBJPROP_STYLE, STYLE_DOT);            
         ObjectSet("PriceAbove_3", OBJPROP_COLOR, PriceAbove_3clr);                  
         ObjectSet("PriceAbove_3", OBJPROP_WIDTH, PriceAbove_3size);                      
      }                                                                    
//----                                                                                                                                       
//----                                                                   
      if (PriceAbove_2 > 0)                                                
      {                                                                    
         ObjectCreate("PriceAbove_2", OBJ_HLINE, 0, Time[0], PriceAbove_2);
         ObjectSet("PriceAbove_2", OBJPROP_STYLE, STYLE_DOT);
         ObjectSet("PriceAbove_2", OBJPROP_COLOR, PriceAbove_2clr);
         ObjectSet("PriceAbove_2", OBJPROP_WIDTH, PriceAbove_2size);
      }
//----
      if (PriceAbove_1 > 0)
      {
         ObjectCreate("PriceAbove_1", OBJ_HLINE, 0, Time[0], PriceAbove_1);
         ObjectSet("PriceAbove_1", OBJPROP_STYLE, STYLE_DOT);
         ObjectSet("PriceAbove_1", OBJPROP_COLOR, PriceAbove_1clr);
         ObjectSet("PriceAbove_1", OBJPROP_WIDTH, PriceAbove_1size);
      }
//----
 
 
return(0);
}
 
int deinit()
      {
       ObjectDelete("PriceAbove_3");
       ObjectDelete("PriceAbove_2");
       ObjectDelete("PriceAbove_1");
//-----    
      return(0);
      }
 
 
 
 
//------
int start()
   {
//---
   if (ObjectGet("PriceAbove_3", 1) != PriceAbove_3)
        PriceAbove_3= ObjectGet("PriceAbove_3", 1);
 
      if (ObjectGet("PriceAbove_2", 1) != PriceAbove_2)
        PriceAbove_2= ObjectGet("PriceAbove_2", 1);
 
      if (ObjectGet("PriceAbove_1", 1) != PriceAbove_1)
        PriceAbove_1= ObjectGet("PriceAbove_1", 1);
 
 
//----
 
      if ((Ask > PriceAbove_3) && (PriceAbove_3 > 0))
      {
         PlaySound(wavarray[PriceAbove_3_wav]);
         SendMail("Price for " + Symbol() +  " above the alert level 3 " + DoubleToStr(Ask,Digits-1), "Price for " + Symbol() +  " reached " + DoubleToStr(Ask,Digits-1) + " level, which is above your alert level of " + DoubleToStr(PriceAbove_3,Digits-1));
         ObjectDelete("PriceAbove_3");
         PriceAbove_3 = 0;
      }
//----
 
      if ((Ask > PriceAbove_2) && (PriceAbove_2 > 0))
      {
         PlaySound(wavarray[PriceAbove_2_wav]);
         SendMail("Price for " + Symbol() +  " above the alert level 2 " + DoubleToStr(Ask,Digits-1), "Price for " + Symbol() +  " reached " + DoubleToStr(Ask,Digits-1) + " level, which is above your alert level of " + DoubleToStr(PriceAbove_2,Digits-1));
         ObjectDelete("PriceAbove_2");
         PriceAbove_2 = 0;
      }
//----
 
      if ((Ask > PriceAbove_1) && (PriceAbove_1 > 0))
      {
         PlaySound(wavarray[PriceAbove_1_wav]);
         SendMail("Price for " + Symbol() +  " above the alert level 1 " + DoubleToStr(Ask,Digits-1), "Price for " + Symbol() +  " reached " + DoubleToStr(Ask,Digits-1) + " level, which is above your alert level of 1 " + DoubleToStr(PriceAbove_1,Digits-1));
         ObjectDelete("PriceAbove_1");
         PriceAbove_1= 0;
      }
//----     
 
 
 
//---
    return(0);
   }
//+------------------------------------------------------------------+
 

Maverick

Master Trader
Apr 3, 2014
323
3
79
Bournemouth UK
hundred is a traffic jam
Hear what you are saying but rather than have 200 watt Yellow light bulbs I was thinking 5 watt DarkBlue on a Black background ... or something similar :)

How does the above code differ from what I already have ?

The lines BELOW price still disappear when you click close

Could it have anything to do with ...

MQL4:
if (PriceAbove_1 > 0)
if (PriceExact_0 > 0)
if (PriceBelow_1 > 0)
 
Should it be
 
if (PriceAbove_1 > 0)
if (PriceExact_0 = 0)
if (PriceBelow_1 < 0)
 
Just my guess

to test your wav file and lines while the market is closed
I can wait a few more hours

.
 

hayseed

Master Trader
Jul 27, 2010
555
157
109
usa
How does the above code differ from what I already have ?

The lines BELOW price still disappear when you click close.. Could it have anything to do with ..
.
//-----

hey maverick...... in the code you sent, you have > in each of the price below conditions..... seems like it should be < ...... try that.... and a 500 watt halogen.... lol.....h

MQL4:
if ((Ask > PriceBelow_1) && (PriceBelow_1 > 0))
//-----