#property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Aqua #property indicator_color4 Orange //---- input parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; extern bool alertsOn = true; extern bool alertsMessage = true; extern bool alertsSound = true; extern bool alertsEmail = false; //---- buffers double Cross_Up[]; double Cross_Down[]; double ZeroCross_Up[]; double ZeroCross_Down[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(4); SetIndexBuffer(0,Cross_Up); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,108); SetIndexBuffer(1,Cross_Down); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,108); SetIndexBuffer(2,ZeroCross_Up); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,233); SetIndexBuffer(3,ZeroCross_Down); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,234); return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- the last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=1; iSignal_1 && MACD_2<= Signal_2 ) {Cross_Up[i] = Low[i]-Range;} if ( MACD_1= Signal_2 ) {Cross_Down[i] = High[i]+Range;} if ( Signal_1>0 && Signal_2 < 0 ) { ZeroCross_Up[i] = Low[i]-Range; if (alertsOn) doAlert(" crossed up"); } if ( Signal_1<0 && Signal_2 > 0 ) { ZeroCross_Down[i] = High[i]+Range; if (alertsOn) doAlert(" crossed down"); } } return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void doAlert(string doWhat) { static string previousAlert = "nothing"; static datetime previousTime; string message; if (previousAlert != doWhat || previousTime != Time[0]) { previousAlert = doWhat; previousTime = Time[0]; message = StringConcatenate(Symbol(), " at ", TimeToStr(TimeLocal(), TIME_SECONDS), " MACD ", doWhat); if (alertsMessage) Alert(message); if (alertsSound) PlaySound("alert2.wav"); if (alertsEmail) SendMail(StringConcatenate(Symbol(), " MACD crossing"), message); } }