

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Red

extern double RSI_Period = 3;
extern int RSI_Overbought = 80;
extern int RSI_Oversold = 20;
extern bool Sound_Alert = TRUE;
double g_ibuf_96[];
double g_ibuf_100[];

int init() {
 
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 221);
   SetIndexBuffer(0, g_ibuf_96);
   SetIndexEmptyValue(0, 0.0);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 222);
   SetIndexBuffer(1, g_ibuf_100);
   SetIndexEmptyValue(1, 0.0);
   return (0);
}

int deinit() {
 
   return (0);
}

int start() {
   double l_iatr_0 = iATR(Symbol(), 0, 50, 1);
   for (int l_index_12 = 0; l_index_12 < Bars; l_index_12++) {
      g_ibuf_96[l_index_12] = 0.0;
      g_ibuf_100[l_index_12] = 0.0;
      for (int l_index_16 = 0; l_index_16 < 2; l_index_16++) lda_8[l_index_16] = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE, l_index_12 + l_index_16);
      if (lda_8[0] > RSI_Oversold && lda_8[1] < RSI_Oversold) g_ibuf_96[l_index_12] = Low[l_index_12] - l_iatr_0 / 2.0;
      if (lda_8[0] < RSI_Overbought && lda_8[1] > RSI_Overbought) g_ibuf_100[l_index_12] = High[l_index_12] + l_iatr_0 / 2.0;
   }
   if (g_ibuf_96[2] == 0.0 && g_ibuf_96[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0]) Alert("RSI Signal: Long Trade");
   if (g_ibuf_100[2] == 0.0 && g_ibuf_100[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0]) Alert("RSI Signal: Short Trade");
   return (0);
}