Navigation:Home > Content >

RSI_Alerttt.mq4

Time: 2013-09-23 | Download file:RSI_Alerttt.mq4

//+------------------------------------------------------------------+
//|                                                  RSI Signals.mq4 |
//|                                 Copyright © 2010, ???? ????????? |
//|                                             tretyak-off@inbox.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, ???? ?????????"
#property link      "tretyak-off@inbox.ru"
 
#property indicator_chart_window
#property indicator_buffers 4
//---- ??? RSI
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int       RSIPeriod=14;
extern double    _Up=75.0; //OverBoughtLevel - ??????? ???????????????
extern double    _Mid=50.0;
extern double    _Down=25.0;//OverSoldLevel - ??????? ???????????????
extern bool      ShowMidSignals=false;
extern bool      SoundON=true;
//---- ??????
extern int       DownArrow=234;
extern int       UpArrow=233;
//---- buffers
double UpBuffer[];
double DownBuffer[];
 
//---- ?????????????
int flagval1=0;
int flagval2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,DownArrow);//????
   SetIndexBuffer(0,UpBuffer);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,UpArrow);//?????
   SetIndexBuffer(1,DownBuffer);
   SetIndexEmptyValue(1,0.0);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit, i, counter;
   double Range, AvgRange;
   double RSIPrev,RSIAnow;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
     for(i=1; i<=limit; i++) 
     {counter=i;Range=0;AvgRange=0;
      for(counter=i ;counter<=i+9;counter++)
        {AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);}
      Range=AvgRange/10;
      RSIPrev=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i+1);
      RSIAnow=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i);
      UpBuffer[i]=EMPTY_VALUE;
      DownBuffer[i]=EMPTY_VALUE;
      if ((RSIPrev<_Down)&&(RSIAnow>_Down))
        {
         if (i==1 && flagval1==0)
           {
            flagval1=1;
            flagval2=0;
            if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
           }
         DownBuffer[i]=Low[i] - Range*0.5;
         UpBuffer[i]=EMPTY_VALUE;
         flagval1=0;
        }
       if ((ShowMidSignals)&&((RSIPrev<_Mid)&&(RSIAnow>_Mid)))
        {
         if (i==1 && flagval1==0)
           {
            flagval1=1;
            flagval2=0;
            if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
           }
         DownBuffer[i]=Low[i] - Range*0.5;
         UpBuffer[i]=EMPTY_VALUE;
         flagval1=0;
        } 
      if ((RSIPrev>_Up)&&(RSIAnow<_Up))
        {
         if (i==1 && flagval2==0)
           {
            flagval2=1;
            flagval1=0;
            if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
           }
         UpBuffer[i]=High[i] + Range*0.5;
         DownBuffer[i]=EMPTY_VALUE;
         flagval2=0;
        }
       if ((ShowMidSignals)&&((RSIPrev>_Mid)&&(RSIAnow<_Mid)))
        {
         if (i==1 && flagval2==0)
           {
            flagval2=1;
            flagval2=0;
            if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
           }
         UpBuffer[i]=High[i] + Range*0.5;
         DownBuffer[i]=EMPTY_VALUE;
         flagval2=0;
        } }               
      
   return(0);
  }
//+------------------------------------------------------------------+

Recommend