#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Black
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Silver
#property indicator_color5 Silver

extern int PercentZona = 9;
extern int FastSMA=5;
extern int SlowSMA=34;
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];

int init() {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(3, DRAW_LINE, 2);
   SetIndexStyle(4, DRAW_LINE, 2);
   IndicatorDigits(Digits + 1);
   SetIndexDrawBegin(0, 34);
   SetIndexDrawBegin(1, 34);
   SetIndexDrawBegin(2, 34);
   SetIndexDrawBegin(3, 34);
   SetIndexDrawBegin(4, 34);
   IndicatorDigits(Digits + 1);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexBuffer(1, g_ibuf_84);
   SetIndexBuffer(2, g_ibuf_88);
   SetIndexBuffer(3, g_ibuf_92);
   SetIndexBuffer(4, g_ibuf_96);
   string ls_0 = "MV AO(" + PercentZona + ")";
   IndicatorShortName(ls_0);
   SetIndexLabel(1, NULL);
   SetIndexLabel(2, NULL);
   SetIndexLabel(3, "������� ���� MAX");
   SetIndexLabel(4, "������� ���� MIN");
   return (0);
}

int start() {
   double ld_12;
   double ld_20;
   double ld_28;
   double ld_36;
   double ld_44;
   int li_8 = IndicatorCounted();

   if (li_8 > 0) li_8--;
   int li_0 = Bars - li_8;
   for (int li_4 = 0; li_4 < li_0; li_4++) 
     g_ibuf_80[li_4] = iMA(NULL, 0, FastSMA, 0, MODE_SMA, PRICE_MEDIAN, li_4) - 
                       iMA(NULL, 0, SlowSMA, 0, MODE_SMA, PRICE_MEDIAN, li_4);
   bool li_60 = TRUE;
   for (li_4 = li_0 - 1; li_4 >= 0; li_4--) {
      ld_20 = g_ibuf_80[li_4];
      ld_12 = g_ibuf_80[li_4 + 1];
      if (ld_20 > ld_12) li_60 = TRUE;
      if (ld_20 < ld_12) li_60 = FALSE;
      if (!li_60) {
         g_ibuf_88[li_4] = ld_20;
         g_ibuf_84[li_4] = 0.0;
      } else {
         g_ibuf_84[li_4] = ld_20;
         g_ibuf_88[li_4] = 0.0;
      }
   }
   double ld_52 = 0.0;
   if (li_4 != 300) li_4 = 300;
   while (li_4 >= 0) {
      ld_28 = MathAbs(g_ibuf_84[li_4]);
      ld_36 = MathAbs(g_ibuf_88[li_4]);
      ld_44 = MathMax(ld_28, ld_36);
      ld_52 = MathMax(ld_44, ld_52);
      li_4--;
   }
   if (li_4 != 300) li_4 = 300;
   ld_36 = PercentZona / 100.0 * ld_52;
   while (li_4 >= 0) {
      g_ibuf_92[li_4] = ld_36;
      g_ibuf_96[li_4] = -ld_36;
      li_4--;
   }
   return (0);
}