/*
   Generated by ex4-to-mq4 decompiler FREEWARE 4.0.451.7
   Website:  ht tp://wWw . MeTAQUo TES. n Et
   E-mail :  suPP Or t@MeT A QUo Te S .nE t
*/
#property copyright "http://dmffx.com"
#property link      "http://dmffx.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red

extern int TF = 0;
extern int Depth = 10;
extern int Shift = 1;
extern int SignalSMA = 5;
extern int period = 5;
extern bool AlertsOn = TRUE;
extern bool ShowArrows = TRUE;
extern int Display = 1;
extern double min = -4.0;
extern double max = 4.0;
double G_ibuf_124[];
double G_ibuf_128[];
double G_ibuf_132[];
double G_ibuf_136[];
double G_ibuf_140[];

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   IndicatorBuffers(5);
   SetIndexBuffer(0, G_ibuf_124);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(1, G_ibuf_128);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(2, G_ibuf_132);
   SetIndexBuffer(3, G_ibuf_136);
   SetIndexBuffer(4, G_ibuf_140);
   switch (Display) {
   case 1:
      SetLevelValue(2, min);
      SetLevelValue(3, max);
      SetLevelStyle(2, 1, DarkKhaki);
      break;
   case 2:
      SetLevelValue(2, 0);
      SetLevelValue(3, 0);
   default:
      Display = 2;
   }
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   for (int Li_0 = ObjectsTotal() - 1; Li_0 >= 0; Li_0--)
      if (StringSubstr(ObjectName(Li_0), 0, StringLen("MA_SE_")) == "MA_SE_") ObjectDelete(ObjectName(Li_0));
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_12;
   double ihigh_16;
   double ilow_24;
   double Ld_32;
   double Ld_40;
   int ind_counted_0 = IndicatorCounted();
   int Li_4 = Bars - ind_counted_0 - 1;
   if (Li_4 > 1) Li_4 = Bars - Depth - 2;
   for (int Li_8 = Li_4; Li_8 >= 0; Li_8--) {
      Li_12 = iBarShift(NULL, TF, Time[Li_8], TRUE) + Shift;
      ihigh_16 = iHigh(NULL, TF, iHighest(NULL, TF, MODE_HIGH, Depth, Li_12));
      ilow_24 = iLow(NULL, TF, iLowest(NULL, TF, MODE_LOW, Depth, Li_12));
      if (Close[Li_8] - (ihigh_16 + ilow_24) / 2.0 > 0.0) G_ibuf_140[Li_8] = 1;
      else {
         if (Close[Li_8] - (ihigh_16 + ilow_24) / 2.0 < 0.0) G_ibuf_140[Li_8] = -1;
         else G_ibuf_140[Li_8] = G_ibuf_140[Li_8 + 1];
      }
      Ld_32 = 0;
      Ld_40 = 0;
      for (int Li_48 = Li_8; Li_48 < Li_8 + period; Li_48++) {
         if (G_ibuf_140[Li_48] > 0.0) Ld_32 += G_ibuf_140[Li_48];
         else Ld_40 += G_ibuf_140[Li_48];
      }
      G_ibuf_132[Li_8] = Ld_32;
      G_ibuf_136[Li_8] = Ld_40;
      G_ibuf_124[Li_8] = G_ibuf_132[Li_8] + G_ibuf_136[Li_8];
   }
   for (Li_8 = Li_4; Li_8 >= 0; Li_8--) G_ibuf_128[Li_8] = iMAOnArray(G_ibuf_124, Bars, SignalSMA, 0, MODE_SMA, Li_8);
   for (Li_8 = Li_4; Li_8 >= 0; Li_8--) {
      if (ShowArrows) {
         if (G_ibuf_124[Li_8] > G_ibuf_128[Li_8] && G_ibuf_124[Li_8 + 1] < G_ibuf_128[Li_8] && G_ibuf_124[Li_8] < 0.0 && G_ibuf_128[Li_8] < 0.0) f0_0(Li_8, Blue, SYMBOL_ARROWUP, 0);
         if (G_ibuf_124[Li_8] < G_ibuf_128[Li_8] && G_ibuf_124[Li_8 + 1] > G_ibuf_128[Li_8] && G_ibuf_124[Li_8] > 0.0 && G_ibuf_128[Li_8] > 0.0) f0_0(Li_8, Red, SYMBOL_ARROWDOWN, 1);
      }
   }
   return (0);
}

// 83352185C0DFB1AB94B9BFBEB80DECFE
void f0_0(int Ai_0, color A_color_4, int Ai_8, bool Ai_12) {
   string name_16 = "MA_SE_" + Time[Ai_0];
   double iatr_24 = iATR(NULL, 0, 10, Ai_0);
   ObjectCreate(name_16, OBJ_ARROW, 0, Time[Ai_0], 0);
   ObjectSet(name_16, OBJPROP_ARROWCODE, Ai_8);
   ObjectSet(name_16, OBJPROP_COLOR, A_color_4);
   if (Ai_12) {
      ObjectSet(name_16, OBJPROP_PRICE1, High[Ai_0] + 0.0 * iatr_24);
      return;
   }
   ObjectSet(name_16, OBJPROP_PRICE1, Low[Ai_0] - 0.0 * iatr_24);
}
