//+------------------------------------------------------------------+ //| RSI_Alerts.mq4 | //| Copyright © 2006, Forex-Experts | //| http://www.forex-experts.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, Forex-Experts" #property link "http://www.forex-experts.com" //---- input parameters //For alert system extern int RSI_Period=9; extern double RSI_LevelUp=70; extern double RSI_LevelDn=30; extern int Repeat=3,Periods=5; extern int UseAlert=1; extern int SendEmail=0; extern int Bar=1; extern string Sound="alert2.wav"; int Crepeat=0; int AlertTime=0; double RSI_cur=0,RSI_prev=0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Crepeat=Repeat; //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Value=0; //---- int CrossDn=0,CrossUp=0; CrossDn=0;CrossUp=0; RSI_cur=iRSI(NULL,0,RSI_Period,0,0+Bar); RSI_prev=iRSI(NULL,0,RSI_Period,0,1+Bar); //Comment("RSI_cur=",RSI_cur," RSI_prev=",RSI_prev); if (RSI_cur>RSI_LevelUp && RSI_prevRSI_LevelDn) CrossDn=1; else CrossDn=0; string AlertStr=""; AlertStr=""; //Alert system if (UseAlert==1) { if (CrossDn==1) { if (Crepeat==Repeat) { AlertTime=0; } if (Crepeat>0 && (CurTime()-AlertTime)>Periods) { if (CrossDn==1) AlertStr=AlertStr+"Attention! RSI has crossed below level "+DoubleToStr(RSI_LevelDn,2); Alert(Symbol()," ",Period(), ": ", AlertStr); PlaySound(Sound); if (SendEmail==1) { SendMail(Symbol()+" "+Period()+ ": ",Symbol()+" "+Period()+": "+AlertStr); } Crepeat=Crepeat-1; AlertTime=CurTime(); } } if (CrossUp==1) { if (Crepeat==Repeat) { AlertTime=0; } if (Crepeat>0 && (CurTime()-AlertTime)>Periods) { if (CrossUp==1) AlertStr=AlertStr+"Attention! RSI has crossed up level "+DoubleToStr(RSI_LevelUp,2); Alert(Symbol()," ",Period(), ": ",AlertStr); PlaySound(Sound); if (SendEmail==1) { SendMail(Symbol()+" "+Period()+ ": ",Symbol()+" "+Period()+": "+AlertStr); } Crepeat=Crepeat-1; AlertTime=CurTime(); } } if (CrossUp==0 && CrossDn==0) { Crepeat=Repeat; AlertTime=0; } } // //---- return(0); } //+------------------------------------------------------------------+