/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website: h T Tp : / /w Ww.M E t a Q u OtES .N eT
   E-mail : s u P p ort @ M e T a QUO t Es.N et
*/

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

extern int rsi_per = 14;
extern double rsi_change_high_level  = 70;

 double rsi_change_low_level;

double G_ibuf_80[];
double G_ibuf_84[];

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 3);
   SetIndexBuffer(0, G_ibuf_80);
   SetIndexBuffer(1, G_ibuf_84);
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
   string Ls_0 = "Trend Direction(" + rsi_per + ")";
   IndicatorShortName(Ls_0);
   SetIndexLabel(0, "UpTrend");
   SetIndexLabel(1, "DownTrend");
   SetIndexDrawBegin(0, rsi_per);
   SetIndexDrawBegin(1, rsi_per);
   
  rsi_change_low_level =  100 - rsi_change_high_level;
   
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_4;
   double irsi_8;
   for (int i = Bars - rsi_per - 1; i >= 0; i--) {
      irsi_8 = iRSI(NULL, 0, rsi_per, PRICE_CLOSE, i);
      if (irsi_8 > rsi_change_high_level) Li_4 = 1;
      if (irsi_8 < rsi_change_low_level) Li_4 = -1;
      if( Li_4 > 0)
        {
         if (irsi_8 > 40.0) G_ibuf_80[i] = 1.0;
         else               G_ibuf_80[i] = 1.0;
         G_ibuf_84[i] = 0;
      }
      if (Li_4 < 0) {
         if (irsi_8 < 60.0) G_ibuf_84[i] = 1.0;
         else               G_ibuf_84[i] = 1.0;
         G_ibuf_80[i] = 0;
      }
   }
   return (0);
}
