Hi all,
I have the attached indicator which identifies pinbars. I'd like to be able to add an alert to it so I get a popup notification in MT4 and push notification through my phone once it identifies the price action on the close of the candle. I have tried my best to follow Hanover's instructions from here: http://www.forexfactory.com/showthread.php?t=299520 but all I get is an alert every time a new candle forms telling me there is a pinbar long and a pinbar short regardless of the candle formation.
The code I inserted was as per Hanover's old thread but amended for the indicators buffers and alert text. Ive copied the three sections below. Can anyone help me get this right. All I want to do is get the indicator to alert me once it has identified the price action as per its original parameters.
// === Section 1: paste this code directly BELOW the final 'extern' statement ================================================================= //
//
extern int AlertCandle = 1; //
extern bool ShowChartAlerts = false; //
extern string AlertEmailSubject = ""; //
//
datetime LastAlertTime = -999999; //
//
string AlertTextPinbarLong = "Pinbar Long"; //---- type your desired text between the quotes //
string AlertTextPinbarShort = "Pinbar Short"; //---- type your desired text between the quotes //
//
// ============================================================================================================================================ //
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// === Section 2: paste this code just BEFORE the final 'return(0)' statement in the start() module =========================================== //
//
ProcessAlerts(); //
//
// ============================================================================================================================================ //
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// === Section 3: paste this code at the end of the indicator ================================================================================= //
//
//+------------------------------------------------------------------+ //
int ProcessAlerts() { //
//+------------------------------------------------------------------+ //
if (AlertCandle >= 0 && Time[0] > LastAlertTime) { //
//
// === Alert processing for Pinbar Long === //
if (dBullPriceActionBuffer[AlertCandle]) { //
string AlertText = Symbol() + "," + TFToStr(Period()) + ": " + AlertTextPinbarLong; //
if (ShowChartAlerts) Alert(AlertText); //
if (AlertEmailSubject > "") SendMail(AlertEmailSubject,AlertText); //
LastAlertTime = Time[0]; //
} //
//
// === Alert processing for Pinbar Short === //
if (dBearPriceActionBuffer[AlertCandle]) { //
AlertText = Symbol() + "," + TFToStr(Period()) + ": " + AlertTextPinbarShort; //
if (ShowChartAlerts) Alert(AlertText); //
if (AlertEmailSubject > "") SendMail(AlertEmailSubject,AlertText); //
LastAlertTime = Time[0]; //
} // //
//
} //
return(0); //
} //
//
//+------------------------------------------------------------------+ //
string TFToStr(int tf) { //
//+------------------------------------------------------------------+ //
if (tf == 0) tf = Period(); //
if (tf >= 43200) return("MN"); //
if (tf >= 10080) return("W1"); //
if (tf >= 1440) return("D1"); //
if (tf >= 240) return("H4"); //
if (tf >= 60) return("H1"); //
if (tf >= 30) return("M30"); //
if (tf >= 15) return("M15"); //
if (tf >= 5) return("M5"); //
if (tf >= 1) return("M1"); //
return(""); //
} //
// ============================================================================================================================================ //
I have the attached indicator which identifies pinbars. I'd like to be able to add an alert to it so I get a popup notification in MT4 and push notification through my phone once it identifies the price action on the close of the candle. I have tried my best to follow Hanover's instructions from here: http://www.forexfactory.com/showthread.php?t=299520 but all I get is an alert every time a new candle forms telling me there is a pinbar long and a pinbar short regardless of the candle formation.
The code I inserted was as per Hanover's old thread but amended for the indicators buffers and alert text. Ive copied the three sections below. Can anyone help me get this right. All I want to do is get the indicator to alert me once it has identified the price action as per its original parameters.
// === Section 1: paste this code directly BELOW the final 'extern' statement ================================================================= //
//
extern int AlertCandle = 1; //
extern bool ShowChartAlerts = false; //
extern string AlertEmailSubject = ""; //
//
datetime LastAlertTime = -999999; //
//
string AlertTextPinbarLong = "Pinbar Long"; //---- type your desired text between the quotes //
string AlertTextPinbarShort = "Pinbar Short"; //---- type your desired text between the quotes //
//
// ============================================================================================================================================ //
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// === Section 2: paste this code just BEFORE the final 'return(0)' statement in the start() module =========================================== //
//
ProcessAlerts(); //
//
// ============================================================================================================================================ //
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// === Section 3: paste this code at the end of the indicator ================================================================================= //
//
//+------------------------------------------------------------------+ //
int ProcessAlerts() { //
//+------------------------------------------------------------------+ //
if (AlertCandle >= 0 && Time[0] > LastAlertTime) { //
//
// === Alert processing for Pinbar Long === //
if (dBullPriceActionBuffer[AlertCandle]) { //
string AlertText = Symbol() + "," + TFToStr(Period()) + ": " + AlertTextPinbarLong; //
if (ShowChartAlerts) Alert(AlertText); //
if (AlertEmailSubject > "") SendMail(AlertEmailSubject,AlertText); //
LastAlertTime = Time[0]; //
} //
//
// === Alert processing for Pinbar Short === //
if (dBearPriceActionBuffer[AlertCandle]) { //
AlertText = Symbol() + "," + TFToStr(Period()) + ": " + AlertTextPinbarShort; //
if (ShowChartAlerts) Alert(AlertText); //
if (AlertEmailSubject > "") SendMail(AlertEmailSubject,AlertText); //
LastAlertTime = Time[0]; //
} // //
//
} //
return(0); //
} //
//
//+------------------------------------------------------------------+ //
string TFToStr(int tf) { //
//+------------------------------------------------------------------+ //
if (tf == 0) tf = Period(); //
if (tf >= 43200) return("MN"); //
if (tf >= 10080) return("W1"); //
if (tf >= 1440) return("D1"); //
if (tf >= 240) return("H4"); //
if (tf >= 60) return("H1"); //
if (tf >= 30) return("M30"); //
if (tf >= 15) return("M15"); //
if (tf >= 5) return("M5"); //
if (tf >= 1) return("M1"); //
return(""); //
} //
// ============================================================================================================================================ //
Attached File(s)
Price Action v2.mq4
4 KB
|
215 downloads