//+------------------------------------------------------------------+ //| Sidus v.3 Entry Indicator.mq4 | //| | //| Ideas by Sidus | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Yellow #property indicator_color2 Red #property indicator_color3 Aqua #property indicator_color4 Yellow #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 3 #property indicator_width4 3 // // // // // extern int FastEMA = 15; extern int SlowEMA = 34; extern string ex = "0=SMA,1=EMA,2=SSMA,3=LWMA"; extern int mamode = MODE_LWMA; extern string ex2 = "0=Close,1=Open,2=High,3=Low"; extern string ex2a = "4=Median,5=Typical,6=Weighted"; extern int maprice = PRICE_CLOSE; extern int RSIPeriod = 8; extern bool alertsOn = true; extern bool alertsOnCurrent = false; extern bool alertsMessage = true; extern bool alertsSound = true; extern bool alertsEmail = false; extern string soundfile = "alert2.wav"; // // // // // // Robert changed buffer names to be more readable double FastMA_Buffer[]; double SlowMA_Buffer[]; double UpArrowBuffer[]; double DownArrowBuffer[]; double trend[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { IndicatorBuffers(5); SetIndexBuffer(0,FastMA_Buffer); SetIndexBuffer(1,SlowMA_Buffer); SetIndexBuffer(2,UpArrowBuffer); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,233); SetIndexBuffer(3,DownArrowBuffer); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,234); SetIndexBuffer(4,trend); return(0); } int deinit() { return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int start() { int counted_bars=IndicatorCounted(); int limit; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=MathMin(Bars-counted_bars,Bars-1); // // // // // for(int i=limit; i>=0; i--) { FastMA_Buffer[i] = iMA(NULL,0,FastEMA,0,mamode,maprice,i); SlowMA_Buffer[i] = iMA(NULL,0,SlowEMA,0,mamode,maprice,i); UpArrowBuffer[i] = EMPTY_VALUE; DownArrowBuffer[i] = EMPTY_VALUE; trend[i] = trend[i+1]; // // // // // double dist = iATR(NULL,0,20,i); double rsi = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i); double diff = (FastMA_Buffer[i]-SlowMA_Buffer[i]); if (diff>0 && rsi>50) trend[i] = 1; if (diff<0 && rsi<50) trend[i] = -1; if (trend[i]!=trend[i+1]) if (trend[i]==1) UpArrowBuffer[i] = FastMA_Buffer[i]-dist; else DownArrowBuffer[i] = FastMA_Buffer[i]+dist; } if (alertsOn) { if (alertsOnCurrent) int whichBar = 0; else whichBar = 1; // // // // // if (trend[whichBar] != trend[whichBar+1]) if (trend[whichBar] == 1) doAlert("uptrend"); else doAlert("downtrend"); } 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)," sidus ",doWhat); if (alertsMessage) Alert(message); if (alertsEmail) SendMail(StringConcatenate(Symbol()," sidus "),message); if (alertsSound) PlaySound(soundfile); } }