/*
   Generated by EX4-TO-MQ4 decompiler FREEWARE V4.0.451.1 [-]
   Website: http://www.metaquotes.net
   E-mail : support@metaquotes.net
*/

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Aqua
#property indicator_color2 Fuchsia
#property indicator_color3 Red
#property indicator_color4 CLR_NONE
#property indicator_color5 CLR_NONE
#property indicator_color6 DeepSkyBlue
#property indicator_color7 DeepPink 
#property indicator_color8 Black

double g_ibuf_76[];
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
bool gi_104;
extern int g_period_108 = 30;
double gd_unused_112 = 0.5;
extern double Multiplier = 3.0;
double g_icustom_128;
bool gi_unused_224 = FALSE;
bool gi_unused_228 = FALSE;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, SYMBOL_ARROWUP);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, SYMBOL_ARROWDOWN);
   SetIndexBuffer(1, g_ibuf_80);
   SetIndexStyle(2, DRAW_LINE, STYLE_DOT, 3, Red);
   SetIndexBuffer(2, g_ibuf_84);
   SetIndexStyle(3, DRAW_LINE, EMPTY);
   SetIndexBuffer(3, g_ibuf_88);
   SetIndexStyle(4, DRAW_LINE, EMPTY);
   SetIndexBuffer(4, g_ibuf_92);
   SetIndexBuffer(5, g_ibuf_96);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 5);
   SetIndexLabel(5, "Trend Up");
   SetIndexBuffer(6, g_ibuf_100);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 5);
   SetIndexLabel(6, "Trend Down");
//   ObjectCreate("mysl_1", OBJ_LABEL, 0, 0, 0);
//   ObjectCreate("mysl_2", OBJ_LABEL, 0, 0, 0);
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   ObjectDelete("mysl_1");
   ObjectDelete("mysl_2");
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   bool li_28;
   bool li_32;
   int lia_36[5000];
   double ld_40;
   double icustom_48;
   double icustom_56;
   double icustom_64;
   double icustom_72;
   double icustom_80;
   double icustom_88;
   double icustom_96;
   double icustom_104;
   double lda_112[5000];
   double lda_116[5000];
   double high_120;
   double low_128;
   double iatr_136;
   double iatr_144;
   int li_0 = 90;
   int li_4 = 2013;
   //int year_8 = TimeYear(TimeCurrent());
   //int day_of_year_12 = TimeDayOfYear(TimeCurrent());
   //if (day_of_year_12 > li_0) Alert("Account Being Disabled Renew Subscription");
   //if (year_8 > li_4) return (-1);
   //if (day_of_year_12 > li_0) return (-1);
   int li_160 = IndicatorCounted();
   if (li_160 < 0) return (-1);
   if (li_160 > 0) li_160--;
   int li_16 = Bars - li_160;
   for (int bars_20 = Bars; bars_20 >= 0; bars_20--) {
      g_ibuf_96[bars_20] = EMPTY_VALUE;
      g_ibuf_100[bars_20] = EMPTY_VALUE;
      iatr_136 = iATR(NULL, 0, g_period_108, bars_20);
      high_120 = High[iHighest(NULL, 0, MODE_HIGH, 10, bars_20)];
      low_128 = Low[iLowest(NULL, 0, MODE_LOW, 10, bars_20)];
      lda_112[bars_20] = high_120;
      lda_116[bars_20] = low_128;
      lia_36[bars_20] = 1;
      iatr_144 = 0;
      iatr_144 = iATR(NULL, 0, 10, bars_20);
      g_icustom_128 = iCustom(NULL, 0, "Profit Indicator", 0, bars_20);
      icustom_56 = iCustom(NULL, 0, "Profit Indicator", 0, bars_20 - 1);
      icustom_72 = iCustom(NULL, 0, "Profit Indicator", 0, bars_20 + 1);
      icustom_88 = iCustom(NULL, 0, "Profit Indicator", 1, bars_20);
      icustom_96 = iCustom(NULL, 0, "Profit Indicator", 1, bars_20 - 1);
      icustom_104 = iCustom(NULL, 0, "Profit Indicator", 1, bars_20 + 1);
      icustom_48 = iCustom(NULL, 0, "Profit Indicator", 4, bars_20);
      icustom_64 = iCustom(NULL, 0, "Profit Indicator", 4, bars_20 - 1);
      icustom_80 = iCustom(NULL, 0, "Profit Indicator", 4, bars_20 + 1);
      if ((g_icustom_128 != 0.0 && g_icustom_128 > icustom_48 && icustom_56 > icustom_64 && icustom_72 > icustom_80) || (ld_40 != 0.0 && icustom_88 > icustom_48 && icustom_96 > icustom_64 &&
         icustom_104 > icustom_80)) {
         g_ibuf_76[bars_20] = High[bars_20] + 0.2 * iatr_144;
         g_ibuf_88[bars_20] = Low[bars_20] - 1.5 * iatr_144;
      } else {
         if ((icustom_88 != 0.0 && g_icustom_128 < icustom_48 && icustom_56 < icustom_64 && icustom_72 < icustom_80) || (icustom_88 != 0.0 && icustom_88 < icustom_48 && icustom_96 < icustom_64 &&
            icustom_104 < icustom_80)) {
            g_ibuf_80[bars_20] = Low[bars_20] - 0.2 * iatr_144;
            g_ibuf_92[bars_20] = High[bars_20] + 1.5 * iatr_144;
         }
      }
      if (High[bars_20] + 0.2 * iatr_144 == g_ibuf_76[bars_20]) {
         lia_36[bars_20] = 1;
         if (lia_36[bars_20 + 1] == -1) gi_104 = TRUE;
      } else {
         if (Low[bars_20] - 0.2 * iatr_144 == g_ibuf_80[bars_20]) {
            lia_36[bars_20] = -1;
            if (lia_36[bars_20 + 1] == 1) gi_104 = TRUE;
         } else {
            if (lia_36[bars_20 + 1] == 1) {
               lia_36[bars_20] = 1;
               gi_104 = FALSE;
            } else {
               if (lia_36[bars_20 + 1] == -1) {
                  lia_36[bars_20] = -1;
                  gi_104 = FALSE;
               }
            }
         }
      }
      if (lia_36[bars_20] < 0 && lia_36[bars_20 + 1] > 0) li_28 = TRUE;
      else li_28 = FALSE;
      if (lia_36[bars_20] > 0 && lia_36[bars_20 + 1] < 0) li_32 = TRUE;
      else li_32 = FALSE;
      if (lia_36[bars_20] > 0 && lda_116[bars_20] < lda_116[bars_20 + 1]) lda_116[bars_20] = lda_116[bars_20 + 1];
      if (lia_36[bars_20] < 0 && lda_112[bars_20] > lda_112[bars_20 + 1]) lda_112[bars_20] = lda_112[bars_20 + 1];
      if (li_28 == TRUE) lda_112[bars_20] = high_120;
      if (li_32 == TRUE) lda_116[bars_20] = low_128;
      if (lia_36[bars_20] == 1) {
         g_ibuf_96[bars_20] = lda_116[bars_20];
         if (gi_104 == TRUE) {
            g_ibuf_96[bars_20 + 1] = g_ibuf_100[bars_20 + 1];
            gi_104 = FALSE;
         }
         if (lia_36[bars_20] == 1 && Close[bars_20] < g_ibuf_96[bars_20]) g_ibuf_84[bars_20] = 0.999 * g_ibuf_96[bars_20];
      } else {
         if (lia_36[bars_20] == -1) {
            g_ibuf_100[bars_20] = lda_112[bars_20];
            if (gi_104 == TRUE) {
               g_ibuf_100[bars_20 + 1] = g_ibuf_96[bars_20 + 1];
               gi_104 = FALSE;
            }
            if (lia_36[bars_20] == -1 && Close[bars_20] > g_ibuf_100[bars_20]) g_ibuf_84[bars_20] = 1.001 * g_ibuf_100[bars_20];
         }
      }
   }
   WindowRedraw();
   return (0);
}