//+------------------------------------------------------------------+ //| Multi-MAX-Alerts.mq4 | //| Hiachiever | //| http://www.The4xTrader.com | //+------------------------------------------------------------------+ #property copyright "Hiachiever" #property link "http://www.The4xTrader.com" extern string Note1 = " -- Moving Averages --"; extern int MA1.Period = 5; extern int MA2.Period = 13; extern int MA3.Period = 34; extern string MANOTE1 = "METHOD INPUTS:"; extern string MANOTE2 = "0=SMA, 1=EMA, 2=SSMA, 3=LWMA"; extern int MA1.Method = MODE_EMA; extern int MA2.Method = MODE_EMA; extern int MA3.Method = MODE_EMA; extern string MANOTE3 = "PRICE INPUTS:"; extern string MANOTE4 = "0=Close, 1=Open, 2=High, 3=Low"; extern string MANOTE5 = "4=Median, 5=Typical, 6=Weighted"; extern int MA1.Price = PRICE_CLOSE; extern int MA2.Price = PRICE_CLOSE; extern int MA3.Price = PRICE_CLOSE; extern int MA1.Shift = 0; extern int MA2.Shift = 0; extern int MA3.Shift = 0; extern string Note2 = " -- Notes to include in Alerts --"; extern string MA1.Note = "."; extern string MA2.Note = "."; extern string MA3.Note = "."; extern string Note3 = " -- Alert Options --"; extern bool UseMA1Alert = True; extern bool UseMA2Alert = True; extern bool UseMA3Alert = True; extern bool AlertOnBarclose = True; extern string soundfile = "alert.wav"; extern bool MsgAlerts= true; extern bool SoundAlerts= true; extern bool eMailAlerts= false; double MA1bid = 0; double MA2bid = 0; double MA3bid = 0; datetime MA1.LastTouchUp, MA1.LastTouchDn,MA2.LastTouchUp,MA2.LastTouchDn,MA3.LastTouchUp,MA3.LastTouchDn; #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { string msg; int BarRef; double EMA1, EMA2, EMA3; bool MA1_CrossUp, MA1_CrossDn, MA2_CrossUp, MA2_CrossDn, MA3_CrossUp, MA3_CrossDn; BarRef = 0; if (AlertOnBarclose) BarRef = 1; EMA1 = iMA(NULL, 0, MA1.Period, MA1.Shift, MA1.Method, MA1.Price, BarRef); EMA2 = iMA(NULL, 0, MA2.Period, MA2.Shift, MA2.Method, MA2.Price, BarRef); EMA3 = iMA(NULL, 0, MA3.Period, MA3.Shift, MA3.Method, MA3.Price, BarRef); MA1_CrossUp = (Open[BarRef] < EMA1) && (Close[BarRef] > EMA1); MA1_CrossDn = (Open[BarRef] > EMA1) && (Close[BarRef] < EMA1); MA2_CrossUp = (Open[BarRef] < EMA2) && (Close[BarRef] > EMA2); MA2_CrossDn = (Open[BarRef] > EMA2) && (Close[BarRef] < EMA2); MA3_CrossUp = (Open[BarRef] < EMA3) && (Close[BarRef] > EMA3); MA3_CrossDn = (Open[BarRef] > EMA3) && (Close[BarRef] < EMA3); if(UseMA1Alert && MA1bid !=0) { if (MA1.LastTouchUp !=Time[BarRef] && MA1_CrossUp) { MA1.LastTouchUp =Time[BarRef]; DoAlerts("Price Crossed up against MA1 - [" + MA1.Period + "]. " +Symbol()+" on time frame "+TF2Str(Period()) + "\nNOTE: " + MA1.Note , "Price Crossed up against MA1 - " + MA1.Period); } if (MA1.LastTouchDn !=Time[BarRef] && MA1_CrossDn) { MA1.LastTouchDn =Time[BarRef]; DoAlerts("Price Crossed down against MA1 - [" + MA1.Period + "]. " +Symbol()+" on time frame "+TF2Str(Period()) + "\nNOTE: " + MA1.Note , "Price Crossed down against MA1 - " + MA1.Period); } } if(UseMA2Alert && MA2bid !=0) { if (MA2.LastTouchUp !=Time[BarRef] && MA2_CrossUp) { MA2.LastTouchUp =Time[BarRef]; DoAlerts("Price Crossed up against MA2 - [" + MA2.Period + "]. " +Symbol()+" on time frame "+TF2Str(Period()) + "\nNOTE: " + MA1.Note , "Price Crossed up against MA2 - " + MA2.Period); } if (MA2.LastTouchDn !=Time[BarRef] && MA2_CrossDn) { MA2.LastTouchDn =Time[BarRef]; DoAlerts("Price Crossed down against MA2 - [" + MA2.Period+ "]. " +Symbol()+" on time frame "+TF2Str(Period()) + "\nNOTE: " + MA1.Note , "Price Crossed down against MA2 - " + MA2.Period); } } if(UseMA3Alert && MA3bid !=0) { if (MA3.LastTouchUp !=Time[BarRef] && MA3_CrossUp) { MA3.LastTouchUp =Time[BarRef]; DoAlerts("Price Crossed up against MA3 - [" + MA3.Period + "]. " +Symbol()+" on time frame "+TF2Str(Period()) + "\nNOTE: " + MA1.Note , "Price Crossed up against MA3 - " + MA3.Period); } if (MA3.LastTouchDn !=Time[BarRef] && MA3_CrossDn) { MA3.LastTouchDn =Time[BarRef]; DoAlerts("Price Crossed down against MA3 - [" + MA3.Period + "]. " +Symbol()+" on time frame "+TF2Str(Period()) + "\nNOTE: " + MA1.Note , "Price Crossed down against MA3 - " + MA3.Period); } } MA1bid = Close[BarRef]; MA2bid = Close[BarRef]; MA3bid = Close[BarRef]; return(0); } //+------------------------------------------------------------------+ void DoAlerts(string MsgText, string emailsub) { if (MsgAlerts) Alert(MsgText); if (SoundAlerts) PlaySound(soundfile); if (eMailAlerts) SendMail(emailsub, MsgText); } string TF2Str(int period) { switch (period) { case PERIOD_M1: return("M1"); case PERIOD_M5: return("M5"); case PERIOD_M15: return("M15"); case PERIOD_M30: return("M30"); case PERIOD_H1: return("H1"); case PERIOD_H4: return("H4"); case PERIOD_D1: return("D1"); case PERIOD_W1: return("W1"); case PERIOD_MN1: return("MN"); } return (Period()); }
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Series array that contains open prices of each bar
Series array that contains open time of each bar
Indicator Curves created:
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen
It plays sound alerts
It sends emails