//+------------------------------------------------------------------+
//|                                                  rsi extreme.mq4 |
//|                                           Author: LordoftheMoney |
//|                                Expert advisor is in the codebase |
//|                                                    (Easiest RSI) |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color1 LightBlue
#property indicator_color2 OrangeRed
extern int rsiperiod = 14;
double buffy1[];
double buffy2[];
int cb=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw;
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexEmptyValue(0,0.0);
   SetIndexLabel(0,"buy");
   SetIndexLabel(1,"sell");
   SetIndexDrawBegin(0,draw);
   SetIndexDrawBegin(1,draw);
   SetIndexBuffer(0,buffy1);
   SetIndexBuffer(1,buffy2);
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   int cb=IndicatorCounted();
   int x;
   if(Bars<=100) return(0);
   if (cb<0) return(-1);
   if (cb>0) cb--;
   x=Bars-cb;
   for(int i=0; i<x; i++)
     {
     double r1 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i);
     double r2 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i+1);
     
     if (r2<30 && r1>30)
      buffy1[i] = Open[i]-15*Point;
     if (r2>70 && r1<70)
      buffy2[i] = Open[i]+15*Point;
     } 

   return(0);
  }
//+------------------------------------------------------------------+