
#property copyright "Copyright © 2012, forex4live.com"
#property link      "http://www.forex4live.com/"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 CLR_NONE
#property indicator_color2 CLR_NONE
#property indicator_color3 Yellow
#property indicator_color4 Yellow
#property indicator_color5 DodgerBlue
#property indicator_color6 Red

extern double Period1 = 12.0;
extern double Period2 = 34.0;
extern double Period3 = 69.0;
extern string Dev_Step_1 = "5,3";
extern string Dev_Step_2 = "5,3";
extern string Dev_Step_3 = "5,3";
extern int Symbol_1_Kod = 172;
extern int Symbol_2_Kod = 174;
extern int Symbol_3_Kod = 82;
extern string _____ = "";
extern bool BoxAlerts = FALSE;
extern bool EmailAlerts = FALSE;
extern bool SoundAlerts = TRUE;
extern bool Alert_Lv1 = FALSE;
extern bool Alert_Lv2 = FALSE;
extern bool Alert_Lv3 = TRUE;
string Gs_168 = "stage one level high.wav";
string Gs_176 = "stage one level low.wav";
string Gs_184 = "stage two level high.wav";
string Gs_192 = "stage two level low.wav";
string Gs_200 = "stage three level high.wav";
string Gs_208 = "stage three level low.wav";
double G_ibuf_216[];
double G_ibuf_220[];
double G_ibuf_224[];
double G_ibuf_228[];
double G_ibuf_232[];
double G_ibuf_236[];
int Gi_unused_240;
int Gi_unused_244;
int Gi_unused_248;
int Gi_252;
int Gi_256;
int Gi_260;
int Gi_264;
int Gi_268;
int Gi_272;
string Gs_276;
string Gs_284;
string Gs_292;
int G_digits_300;
int G_timeframe_304;
bool Gi_308;
bool Gi_312;
bool Gi_316;
int G_bars_320 = -1;
int Gi_unused_324 = 65535;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   string Gsa_0[256];
   int Gia_12[];
   for (int index_4 = 0; index_4 < 256; index_4++) Gsa_0[index_4] = CharToStr(index_4);
   int str2int_8 = StrToInteger(Gsa_0[67] + Gsa_0[111] + Gsa_0[112] + Gsa_0[121] + Gsa_0[32] + Gsa_0[82] + Gsa_0[105] + Gsa_0[103] + Gsa_0[104] + Gsa_0[116] + Gsa_0[32] +
      Gsa_0[169] + Gsa_0[32] + Gsa_0[75] + Gsa_0[97] + Gsa_0[122] + Gsa_0[97] + Gsa_0[111] + Gsa_0[111] + Gsa_0[32] + Gsa_0[50] + Gsa_0[48] + Gsa_0[49] + Gsa_0[49] + Gsa_0[32]);
   G_timeframe_304 = Period();
   Gs_284 = f0_3(G_timeframe_304);
   Gs_276 = Symbol();
   G_digits_300 = Digits;
   Gs_292 = "tbb" + Gs_276 + Gs_284;
   if (Period1 > 0.0) Gi_unused_240 = MathCeil(Period1 * Period());
   else Gi_unused_240 = 0;
   if (Period2 > 0.0) Gi_unused_244 = MathCeil(Period2 * Period());
   else Gi_unused_244 = 0;
   if (Period3 > 0.0) Gi_unused_248 = MathCeil(Period3 * Period());
   else Gi_unused_248 = 0;
   if (Period1 > 0.0) {
      SetIndexStyle(0, DRAW_ARROW);
      SetIndexArrow(0, Symbol_1_Kod);
      SetIndexBuffer(0, G_ibuf_216);
      SetIndexEmptyValue(0, 0.0);
      SetIndexStyle(1, DRAW_ARROW);
      SetIndexArrow(1, Symbol_1_Kod);
      SetIndexBuffer(1, G_ibuf_220);
      SetIndexEmptyValue(1, 0.0);
   }
   if (Period2 > 0.0) {
      SetIndexStyle(2, DRAW_ARROW);
      SetIndexArrow(2, Symbol_2_Kod);
      SetIndexBuffer(2, G_ibuf_224);
      SetIndexEmptyValue(2, 0.0);
      SetIndexStyle(3, DRAW_ARROW);
      SetIndexArrow(3, Symbol_2_Kod);
      SetIndexBuffer(3, G_ibuf_228);
      SetIndexEmptyValue(3, 0.0);
   }
   if (Period3 > 0.0) {
      SetIndexStyle(4, DRAW_ARROW);
      SetIndexArrow(4, Symbol_3_Kod);
      SetIndexBuffer(4, G_ibuf_232);
      SetIndexEmptyValue(4, 0.0);
      SetIndexStyle(5, DRAW_ARROW);
      SetIndexArrow(5, Symbol_3_Kod);
      SetIndexBuffer(5, G_ibuf_236);
      SetIndexEmptyValue(5, 0.0);
   }
   int Li_unused_16 = 0;
   int Li_unused_20 = 0;
   int Li_24 = 0;
   if (f0_0(Dev_Step_1, Li_24, Gia_12) == 1) {
      Gi_256 = Gia_12[1];
      Gi_252 = Gia_12[0];
   }
   if (f0_0(Dev_Step_2, Li_24, Gia_12) == 1) {
      Gi_264 = Gia_12[1];
      Gi_260 = Gia_12[0];
   }
   if (f0_0(Dev_Step_3, Li_24, Gia_12) == 1) {
      Gi_272 = Gia_12[1];
      Gi_268 = Gia_12[0];
   }
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   string Ls_0;
   if (Bars != G_bars_320) {
      Gi_308 = TRUE;
      Gi_312 = TRUE;
      Gi_316 = TRUE;
   }
   if (Period1 > 0.0) f0_1(G_ibuf_216, G_ibuf_220, Period1, Gi_252, Gi_256);
   if (Period2 > 0.0) f0_1(G_ibuf_224, G_ibuf_228, Period2, Gi_260, Gi_264);
   if (Period3 > 0.0) f0_1(G_ibuf_232, G_ibuf_236, Period3, Gi_268, Gi_272);
   string Ls_8 = Gs_276 + "  " + Gs_284 + " at " + DoubleToStr(Close[0], G_digits_300);
   if (Gi_308 && Alert_Lv1) {
      if (G_ibuf_216[0] != 0.0) {
         Gi_308 = FALSE;
         Ls_0 = " FL11: Standby..Level 1 Low;  ";
         if (BoxAlerts) Alert(Ls_0, Ls_8);
         if (EmailAlerts) SendMail(Ls_0, Ls_8);
         if (SoundAlerts) PlaySound(Gs_176);
      }
      if (G_ibuf_220[0] != 0.0) {
         Gi_308 = FALSE;
         Ls_0 = " FL11: Standby..Level 1 High; ";
         if (BoxAlerts) Alert(Ls_0, Ls_8);
         if (EmailAlerts) SendMail(Ls_0, Ls_8);
         if (SoundAlerts) PlaySound(Gs_168);
      }
   }
   if (Gi_312 && Alert_Lv2) {
      if (G_ibuf_224[0] != 0.0) {
         Gi_312 = FALSE;
         Ls_0 = " FL11: Standby..Level 2 Low;  ";
         if (BoxAlerts) Alert(Ls_0, Ls_8);
         if (EmailAlerts) SendMail(Ls_0, Ls_8);
         if (SoundAlerts) PlaySound(Gs_192);
      }
      if (G_ibuf_228[0] != 0.0) {
         Gi_312 = FALSE;
         Ls_0 = " FL11: Standby..Level 2 High; ";
         if (BoxAlerts) Alert(Ls_0, Ls_8);
         if (EmailAlerts) SendMail(Ls_0, Ls_8);
         if (SoundAlerts) PlaySound(Gs_184);
      }
   }
   if (Gi_316 && Alert_Lv3) {
      if (G_ibuf_232[0] != 0.0) {
         Gi_316 = FALSE;
         Ls_0 = " FL11: Standby..Level 3 Low;  ";
         if (BoxAlerts) Alert(Ls_0, Ls_8);
         if (EmailAlerts) SendMail(Ls_0, Ls_8);
         if (SoundAlerts) PlaySound(Gs_208);
      }
      if (G_ibuf_236[0] != 0.0) {
         Gi_316 = FALSE;
         Ls_0 = " FL11: Standby..Level 3 High; ";
         if (BoxAlerts) Alert(Ls_0, Ls_8);
         if (EmailAlerts) SendMail(Ls_0, Ls_8);
         if (SoundAlerts) PlaySound(Gs_200);
      }
   }
   G_bars_320 = Bars;
   return (0);
}

// BE5275EB85F7B577DA8FD065F994B740
string f0_3(int Ai_0) {
   string Ls_ret_4;
   switch (Ai_0) {
   case 1:
      Ls_ret_4 = "M1";
      break;
   case 5:
      Ls_ret_4 = "M5";
      break;
   case 15:
      Ls_ret_4 = "M15";
      break;
   case 30:
      Ls_ret_4 = "M30";
      break;
   case 60:
      Ls_ret_4 = "H1";
      break;
   case 240:
      Ls_ret_4 = "H4";
      break;
   case 1440:
      Ls_ret_4 = "D1";
      break;
   case 10080:
      Ls_ret_4 = "W1";
      break;
   case 43200:
      Ls_ret_4 = "MN";
   }
   return (Ls_ret_4);
}

// 3CA4C22A90227AC4A7684A00FAEE2BA5
int f0_1(double &Gda_0[], double &Gda_4[], int Ai_8, int Ai_12, int Ai_16) {
   double Ld_20;
   double Ld_28;
   double Ld_36;
   double Ld_44;
   double Ld_52;
   double Ld_60;
   for (int Li_68 = Bars - Ai_8; Li_68 >= 0; Li_68--) {
      Ld_20 = Low[iLowest(NULL, 0, MODE_LOW, Ai_8, Li_68)];
      if (Ld_20 == Ld_60) Ld_20 = 0.0;
      else {
         Ld_60 = Ld_20;
         if (Low[Li_68] - Ld_20 > Ai_12 * Point) Ld_20 = 0.0;
         else {
            for (int Li_72 = 1; Li_72 <= Ai_16; Li_72++) {
               Ld_28 = Gda_0[Li_68 + Li_72];
               if (Ld_28 != 0.0 && Ld_28 > Ld_20) Gda_0[Li_68 + Li_72] = 0.0;
            }
         }
      }
      Gda_0[Li_68] = Ld_20;
      Ld_20 = High[iHighest(NULL, 0, MODE_HIGH, Ai_8, Li_68)];
      if (Ld_20 == Ld_52) Ld_20 = 0.0;
      else {
         Ld_52 = Ld_20;
         if (Ld_20 - High[Li_68] > Ai_12 * Point) Ld_20 = 0.0;
         else {
            for (Li_72 = 1; Li_72 <= Ai_16; Li_72++) {
               Ld_28 = Gda_4[Li_68 + Li_72];
               if (Ld_28 != 0.0 && Ld_28 < Ld_20) Gda_4[Li_68 + Li_72] = 0.0;
            }
         }
      }
      Gda_4[Li_68] = Ld_20;
   }
   Ld_52 = -1;
   int Li_76 = -1;
   Ld_60 = -1;
   int Li_80 = -1;
   for (Li_68 = Bars - Ai_8; Li_68 >= 0; Li_68--) {
      Ld_36 = Gda_0[Li_68];
      Ld_44 = Gda_4[Li_68];
      if (Ld_36 == 0.0 && Ld_44 == 0.0) continue;
      if (Ld_44 != 0.0) {
         if (Ld_52 > 0.0) {
            if (Ld_52 < Ld_44) Gda_4[Li_76] = 0;
            else Gda_4[Li_68] = 0;
         }
         if (Ld_52 < Ld_44 || Ld_52 < 0.0) {
            Ld_52 = Ld_44;
            Li_76 = Li_68;
         }
         Ld_60 = -1;
      }
      if (Ld_36 != 0.0) {
         if (Ld_60 > 0.0) {
            if (Ld_60 > Ld_36) Gda_0[Li_80] = 0;
            else Gda_0[Li_68] = 0;
         }
         if (Ld_36 < Ld_60 || Ld_60 < 0.0) {
            Ld_60 = Ld_36;
            Li_80 = Li_68;
         }
         Ld_52 = -1;
      }
   }
   for (Li_68 = Bars - 1; Li_68 >= 0; Li_68--) {
      if (Li_68 >= Bars - Ai_8) Gda_0[Li_68] = 0.0;
      else {
         Ld_28 = Gda_4[Li_68];
         if (Ld_28 != 0.0) Gda_4[Li_68] = Ld_28;
      }
   }
   return (0);
}

// AAE96DC27D91DCB4DC46AF7044ED6795
int f0_2(string As_0, int &Ai_8, int &Gia_12[]) {
   int Li_16;
   int str2int_20 = StrToInteger(As_0);
   if (str2int_20 > 0) {
      Ai_8++;
      Li_16 = ArrayResize(Gia_12, Ai_8);
      if (Li_16 == 0) return (-1);
      Gia_12[Ai_8 - 1] = str2int_20;
      return (1);
   }
   return (0);
}

// 1312C2179DB8967F4CB75C9D549CFB81
int f0_0(string As_0, int &Ai_8, int Gia_12[]) {
   string Ls_16;
   if (StringLen(As_0) == 0) return (-1);
   string Ls_24 = As_0;
   int Li_32 = 0;
   Ai_8 = 0;
   ArrayResize(Gia_12, Ai_8);
   while (StringLen(Ls_24) > 0) {
      Li_32 = StringFind(Ls_24, ",");
      if (Li_32 > 0) {
         Ls_16 = StringSubstr(Ls_24, 0, Li_32);
         Ls_24 = StringSubstr(Ls_24, Li_32 + 1, StringLen(Ls_24));
      } else {
         if (StringLen(Ls_24) > 0) {
            Ls_16 = Ls_24;
            Ls_24 = "";
         }
      }
      if (f0_2(Ls_16, Ai_8, Gia_12) == 0) return (-2);
   }
   return (1);
}