/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2005, klot"
#property link      "klot@mail.ru"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Magenta

extern int Risk = 5;
extern int Candels = 60;
double g_ibuf_84[];
double g_ibuf_88[];
int gia_92[];

int init() {
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 159);
   SetIndexBuffer(0, g_ibuf_84);
   SetIndexEmptyValue(0, 0.0);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 159);
   SetIndexBuffer(1, g_ibuf_88);
   SetIndexEmptyValue(1, 0.0);
   if (Period() > Candels) {
      Alert("DT-ZigZag: Текущий таймфрейм должен быть меньше чем ", Candels);
      return (0);
   }
   ArrayCopySeries(gia_92, 5, Symbol(), Candels);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int l_count_8;
   double l_icustom_12;
   if (Year() >= 2007 && Month() >= 12 && Day() >= 12) return (0);
   int li_0 = IndicatorCounted();
   int li_4 = 300;
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   li_4 = Bars - li_0;
   for (int l_index_20 = 0; l_index_20 < li_4; l_index_20++) {
      if (Time[l_index_20] >= gia_92[0]) l_count_8 = 0;
      else {
         l_count_8 = ArrayBsearch(gia_92, Time[l_index_20 - 1], WHOLE_ARRAY, 0, MODE_DESCEND);
         if (Period() <= Candels) l_count_8++;
      }
      for (int li_24 = l_count_8; li_24 < l_count_8 + 100; li_24++) {
         l_icustom_12 = iCustom(NULL, Candels, "ZigZag", Risk, 5, 3, 0, li_24 + 1);
         if (l_icustom_12 != 0.0) break;
      }
      if (iClose(NULL, 0, l_index_20 + 1) <= l_icustom_12) g_ibuf_88[l_index_20] = l_icustom_12;
      else g_ibuf_88[l_index_20] = 0.0;
      if (iClose(NULL, 0, l_index_20 + 1) >= l_icustom_12) g_ibuf_84[l_index_20] = l_icustom_12;
      else g_ibuf_84[l_index_20] = 0.0;
      ObjectsRedraw();
   }
   return (0);
}