//+------------------------------------------------------------------+ //| MAofRSI.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Lime #property indicator_color2 Red #property indicator_level1 50 #property indicator_levelcolor DimGray //--- input parameters extern int RSIPeriod = 21; extern int MAofRSI = 3; extern int MAofRSI2 = 21; extern int MA_method = 1; //Mode EMA extern bool AudioAlert=true; extern bool EmailAlert=false; //--- buffers double RSIBuffer[]; double MAofRSIBuffer[]; double MAofRSIBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //--- 2 buffers used for counting. IndicatorBuffers(3); SetIndexBuffer(0,MAofRSIBuffer); SetIndexBuffer(1,MAofRSIBuffer2); SetIndexBuffer(2,RSIBuffer); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2); //--- name for DataWindow and indicator subwindow label IndicatorShortName("MARSI("+RSIPeriod+","+MAofRSI+","+MAofRSI2+")"); SetIndexLabel(0,"RSI1("+MAofRSI+")"); SetIndexLabel(1,"RSI2("+MAofRSI2+")"); return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int i; int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //--- main loops 1 and 2 for(i=0; i < limit; i++) { RSIBuffer[i]=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i); } for(i=0; i < limit; i++) { MAofRSIBuffer[i]=iMAOnArray(RSIBuffer,0,MAofRSI,0,MA_method,i); MAofRSIBuffer2[i]=iMAOnArray(RSIBuffer,0,MAofRSI2,0,MA_method,i); } if (AudioAlert) { static int audio; if ((MAofRSIBuffer[1]>MAofRSIBuffer2[1]) && audio!=1) {audio=1; Alert ("RSI UP BUY on ",Symbol()," ",Period()," Minute Chart");} if ((MAofRSIBuffer[1]MAofRSIBuffer2[1]) && email!=1) {email=1; SendMail ("RSI UP BUY on "+Symbol()+" "+Period()+" Minute Chart","CROSS UP BUY on "+Symbol()+" "+Period()+" Minute Chart");} if ((MAofRSIBuffer[1]