/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website:  HT t p :/ / wWw.m eT a qUO t ES . NE t
   E-mail :  s upP or t@ METaQUO T E S.N et
*/
#property copyright "Copyright © 2012, Vladimir Hlystov"
#property link      "cmillion@narod.ru"

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_levelwidth 0
#property indicator_buffers 8
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 Blue
#property indicator_color4 Yellow
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
#property indicator_width1 1
#property indicator_style1 2
#property indicator_level1 15.0
#property indicator_width2 1
#property indicator_style2 2
#property indicator_level2 85.0

extern bool AlertON = FALSE;
extern bool DrawARROW = TRUE;
extern int LevelUp = 85;
extern int LevelDn = 15;
double G_ibuf_92[];
double G_ibuf_96[];
double G_ibuf_100[];
double G_ibuf_104[];
double G_ibuf_108[];
double G_ibuf_112[];
double G_ibuf_116[];
double G_ibuf_120[];
int Gi_124;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, G_ibuf_92);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, G_ibuf_96);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, G_ibuf_100);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, G_ibuf_104);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, G_ibuf_108);
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, G_ibuf_112);
   SetIndexStyle(6, DRAW_LINE);
   SetIndexBuffer(6, G_ibuf_116);
   SetIndexStyle(7, DRAW_LINE);
   SetIndexBuffer(7, G_ibuf_120);
   SetIndexLabel(0, "(6, 3, 3)");
   SetIndexLabel(1, "(9, 3, 3)");
   SetIndexLabel(2, "(12, 3, 3)");
   SetIndexLabel(3, "(14, 3, 3)");
   SetIndexLabel(4, "(16, 3, 3)");
   SetIndexLabel(5, "(19, 3, 3)");
   SetIndexLabel(6, "(21, 3, 3)");
   SetIndexLabel(7, "(24, 3, 3)");
   string Ls_0 = "Spuds Stochastic";
   IndicatorShortName(Ls_0);
   ObjectCreate("SpudsStochastic_on", OBJ_LABEL, WindowFind(Ls_0), 0, 0);
   ObjectSet("SpudsStochastic_on", OBJPROP_CORNER, 0);
   ObjectSet("SpudsStochastic_on", OBJPROP_XDISTANCE, 5);
   ObjectSet("SpudsStochastic_on", OBJPROP_YDISTANCE, 15);
   if (AlertON) ObjectSetText("SpudsStochastic_on", "Alert ON", 8, "Arial", Blue);
   else ObjectSetText("SpudsStochastic_on", "Alert OFF", 8, "Arial", Red);
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   string str_concat_8;
   int Li_0 = IndicatorCounted();
   if (Li_0 > 0) Li_0--;
   int Li_4 = Bars - Li_0;
   for (int shift_16 = Li_4; shift_16 >= 0; shift_16--) {
      G_ibuf_92[shift_16] = iStochastic(NULL, 0, 6, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_96[shift_16] = iStochastic(NULL, 0, 9, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_100[shift_16] = iStochastic(NULL, 0, 12, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_104[shift_16] = iStochastic(NULL, 0, 14, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_108[shift_16] = iStochastic(NULL, 0, 16, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_112[shift_16] = iStochastic(NULL, 0, 19, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_116[shift_16] = iStochastic(NULL, 0, 21, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      G_ibuf_120[shift_16] = iStochastic(NULL, 0, 24, 3, 3, MODE_SMA, 0, MODE_MAIN, shift_16);
      if ((G_ibuf_92[shift_16 + 1] > LevelUp && G_ibuf_96[shift_16 + 1] > LevelUp && G_ibuf_100[shift_16 + 1] > LevelUp && G_ibuf_104[shift_16 + 1] > LevelUp && G_ibuf_108[shift_16 +
         1] > LevelUp && G_ibuf_112[shift_16 + 1] > LevelUp && G_ibuf_116[shift_16 + 1] > LevelUp && G_ibuf_120[shift_16 + 1] > LevelUp) || (G_ibuf_92[shift_16 + 1] < LevelDn && G_ibuf_96[shift_16 + 1] < LevelDn && G_ibuf_100[shift_16 + 1] < LevelDn && G_ibuf_104[shift_16 + 1] < LevelDn && G_ibuf_108[shift_16 + 1] < LevelDn && G_ibuf_112[shift_16 + 1] < LevelDn && G_ibuf_116[shift_16 + 1] < LevelDn && G_ibuf_120[shift_16 + 1] < LevelDn)) Gi_124 = 0;
      if (G_ibuf_92[shift_16] > LevelDn && G_ibuf_96[shift_16] > LevelDn && G_ibuf_100[shift_16] > LevelDn && G_ibuf_104[shift_16] > LevelDn && G_ibuf_108[shift_16] > LevelDn &&
         G_ibuf_112[shift_16] > LevelDn && G_ibuf_116[shift_16] > LevelDn && G_ibuf_120[shift_16] > LevelDn && G_ibuf_92[shift_16 + 1] < LevelDn || G_ibuf_96[shift_16 + 1] < LevelDn ||
         G_ibuf_100[shift_16 + 1] < LevelDn || G_ibuf_104[shift_16 + 1] < LevelDn || G_ibuf_108[shift_16 + 1] < LevelDn || G_ibuf_112[shift_16 + 1] < LevelDn || G_ibuf_116[shift_16 +
         1] < LevelDn || G_ibuf_120[shift_16 + 1] < LevelDn) {
         if (DrawARROW && Gi_124 == 0) {
            str_concat_8 = StringConcatenate("SpudsStochasticb_", TimeToStr(Time[shift_16], TIME_DATE|TIME_MINUTES));
            ObjectDelete(str_concat_8);
            ObjectCreate(str_concat_8, OBJ_ARROW, 0, Time[shift_16], Low[shift_16], 0, 0, 0, 0);
            ObjectSet(str_concat_8, OBJPROP_ARROWCODE, 236);
            ObjectSet(str_concat_8, OBJPROP_COLOR, Blue);
            Gi_124 = 1;
         }
         if (AlertON && shift_16 < 2) Alert(Symbol() + " Spuds Stochastic Buy");
      }
      if (G_ibuf_92[shift_16] < LevelUp && G_ibuf_96[shift_16] < LevelUp && G_ibuf_100[shift_16] < LevelUp && G_ibuf_104[shift_16] < LevelUp && G_ibuf_108[shift_16] < LevelUp &&
         G_ibuf_112[shift_16] < LevelUp && G_ibuf_116[shift_16] < LevelUp && G_ibuf_120[shift_16] < LevelUp && G_ibuf_92[shift_16 + 1] > LevelUp || G_ibuf_96[shift_16 + 1] > LevelUp ||
         G_ibuf_100[shift_16 + 1] > LevelUp || G_ibuf_104[shift_16 + 1] > LevelUp || G_ibuf_108[shift_16 + 1] > LevelUp || G_ibuf_112[shift_16 + 1] > LevelUp || G_ibuf_116[shift_16 +
         1] > LevelUp || G_ibuf_120[shift_16 + 1] > LevelUp) {
         if (DrawARROW && Gi_124 == 0) {
            str_concat_8 = StringConcatenate("SpudsStochastics_", TimeToStr(Time[shift_16], TIME_DATE|TIME_MINUTES));
            ObjectDelete(str_concat_8);
            ObjectCreate(str_concat_8, OBJ_ARROW, 0, Time[shift_16], High[shift_16], 0, 0, 0, 0);
            ObjectSet(str_concat_8, OBJPROP_ARROWCODE, 238);
            ObjectSet(str_concat_8, OBJPROP_COLOR, Red);
            Gi_124 = -1;
         }
         if (AlertON && shift_16 < 2) Alert(Symbol() + " Spuds Stochastic Sell");
      }
   }
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   f0_0("SpudsStochastics_");
   f0_0("SpudsStochasticb_");
   return (0);
}

// 01FDFC7FC92C3F23C8A326305AA47634
int f0_0(string As_0) {
   string name_12;
   string Ls_20;
   for (int Li_8 = ObjectsTotal() - 1; Li_8 >= 0; Li_8--) {
      name_12 = ObjectName(Li_8);
      Ls_20 = StringSubstr(name_12, 0, StringLen(As_0));
      if (Ls_20 == As_0) ObjectDelete(name_12);
   }
   return (0);
}
