Page 1 of 1

changing sound alert for indicator

Posted: Thu Jun 16, 2011 1:06 pm
by Don_xyZ
I found this indicator very useful especially when used in H4 or D1. what i love is this indicator also incorporate alert which is very helpful not to stick to monitor watching the chart all day long.

the problem, however, is the alert sound is the same for buy signal and sell signal.

the request is can anyone with the knowledge help me to differentiate between the alert sound for buy and sell signal? i know kreslik is full of talented trader/coder :)

here's the code for the indicator (the indi belongs to TRO):


//+------------------------------------------------------------------+
//| TRO_Prev_HL |
//| |
//| Copyright ? 2009, Avery T. Horton, Jr. aka TheRumpledOne |
//| |
//| PO BOX 43575, TUCSON, AZ 85733 |
//| |
//| GIFTS AND DONATIONS ACCEPTED |
//| All my indicators should be considered donationware. That is |
//| you are free to use them for your personal use, and are |
//| under no obligation to pay for them. However, if you do find |
//| this or any of my other indicators help you with your trading |
//| then any Gift or Donation as a show of appreciation is |
//| gratefully accepted. |
//| |
//| Gifts or Donations also keep me motivated in producing more |
//| great free indicators. :-) |
//| |
//| PayPal - THERUMPLEDONE@GMAIL.COM |
//+------------------------------------------------------------------+
//| Use http://therumpledone.mbtrading.com/fx/ as your forex broker |
//| ...tell them therumpledone sent you! |
//+------------------------------------------------------------------+


#property copyright "Copyright ? 2009, Avery T. Horton, Jr. aka TRO"
#property link "http://www.therumpledone.com/"


#property indicator_chart_window
#property indicator_buffers 0

#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Magenta

extern bool Send.Mail = false ;

extern bool Sound.Alert = true ;

extern int myPeriod = 1440 ;




string tHIGH0 = "HIGH_0" ;
string tLOW0 = "LOW_0" ;
string tMIDDLE1 = "MIDDLE_1" ;

datetime Trigger ;
string symbol, tChartPeriod, tShortName ;
int digits, period, digits2 ;
double point ;

bool AlertLong, AlertShort ;

//+------------------------------------------------------------------+
int init()
{
if(myPeriod == 0) { period = Period() ; } else { period = myPeriod ; }

symbol = Symbol() ;
digits = Digits ;
point = Point ;

if(digits == 5 || digits == 3) { digits = digits - 1 ; point = point * 10 ; }


string short_name="TRO_PREV_HL";
IndicatorShortName(short_name);

deinit();

return(0);
}
//+------------------------------------------------------------------+
int deinit()
{


ObjectDelete(tHIGH0);
ObjectDelete(tLOW0);
ObjectDelete(tMIDDLE1);
TRO() ;

return(0);
}
//+------------------------------------------------------------------+
int start()
{

int i, dayi, counted_bars = IndicatorCounted();

if(counted_bars < 0)
return(-1);

if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;

for(i = limit - 1; i >= 0; i--)
{
double X01 = iHigh(NULL,period,i+1) ;
double X02 = iLow(NULL,period,i+1) ;
double X03 = (X01 + X02) * 0.5 ;
}


if( High[0] <= X01 ) { AlertShort = true ; } else { AlertShort = false ; }
if( Low[0] >= X02 ) { AlertLong = true ; } else { AlertLong = false ; }

DoAlert() ;

if (ObjectFind(tHIGH0) != 0)
{

ObjectCreate(tHIGH0,OBJ_ARROW,0,Time[0],X01);
ObjectSet(tHIGH0,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(tHIGH0,OBJPROP_COLOR,indicator_color1);
}
else
{
ObjectMove(tHIGH0,0,Time[0],X01);
}



if (ObjectFind(tLOW0) != 0)
{
ObjectCreate(tLOW0,OBJ_ARROW,0,Time[0],X02);
ObjectSet(tLOW0,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(tLOW0,OBJPROP_COLOR,indicator_color2);
}
else
{
ObjectMove(tLOW0,0,Time[0],X02);
}


if (ObjectFind(tMIDDLE1) != 0)
{
ObjectCreate(tMIDDLE1,OBJ_ARROW,0,Time[0],X03);
ObjectSet(tMIDDLE1,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(tMIDDLE1,OBJPROP_COLOR,indicator_color3);
}
else
{
ObjectMove(tMIDDLE1,0,Time[0],X03);
}

return(0);
}

//+--------- TRO MODIFICATION ---------------------------------------+
void DoAlert()
{


if ( Trigger != Time[0] )
{
if( Sound.Alert )
{
if( AlertLong ) { Trigger = Time[0] ; Alert(symbol," ", " Close above previous Low " + DoubleToStr(Close[0] ,digits)); }
if( AlertShort ) { Trigger = Time[0] ; Alert(symbol," ", " Close below previous High "+ DoubleToStr(Close[0] ,digits)); }
}

if( Send.Mail )
{
if( AlertLong ) { Trigger = Time[0] ; SendMail(symbol, "Close above previous High "); }
if( AlertShort ) { Trigger = Time[0] ; SendMail(symbol, "Close below previous Low "); }
}
} // if

}

//+------------------------------------------------------------------+
void TRO()
{

string tObjName03 = "TROTAG" ;
ObjectCreate(tObjName03, OBJ_LABEL, 0, 0, 0);//HiLow LABEL
ObjectSetText(tObjName03, CharToStr(78) , 12 , "Wingdings", DimGray );
ObjectSet(tObjName03, OBJPROP_CORNER, 3);
ObjectSet(tObjName03, OBJPROP_XDISTANCE, 5 );
ObjectSet(tObjName03, OBJPROP_YDISTANCE, 5 );
}


//+------------------------------------------------------------------+



please help :)


i also attached the indicator below.

Posted: Thu Jun 16, 2011 2:17 pm
by forexjake80

Posted: Fri Jun 17, 2011 12:47 am
by Don_xyZ
forexjake80 wrote:http://docs.mql4.com/common/PlaySound


Thanks for the help forexjake80 :)
i really appreciate it!

however, forgive me for saying this...

i'm illiterate when it comes to coding so i don't know where to put the code that you referred to in your post :(

so if you don't mind, please point where to put that code in the indi code or what to change in that indi code :)

Posted: Fri Jun 17, 2011 12:53 am
by Don_xyZ
i almost forgot...

what i want to do is to have the buy signal play alert.wav sound and the sell signal play alert2.wav sound.

Posted: Fri Jun 17, 2011 7:41 am
by forexjake80
just replace the Alert with the PlaySound funtion. Alert function gives a pop up and pops the messge you tell it to in the (). PlaySound does not give you a pop up, but you can tell it which sound file to play in the ()part. make sure to include the "" and the sound files have to be in the correct folder.

if( Sound.Alert )
{
if( AlertLong ) { Trigger = Time[0] ; PlaySound("alert.wav"); }
if( AlertShort ) { Trigger = Time[0] ; PlaySound("alert2.wav"); }
}

Posted: Mon Jun 20, 2011 12:20 am
by Don_xyZ
thank you, forexjake80!

i don't really need the popup anyway, i only need it to sound different for each signal. the indi is now working as i wanted it to.