/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website: H tT p: // wWW.metA Quo tEs .N eT
   E-mail :  S U pPOrt@ m e tA Quo t es .N E T
*/

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 White
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 Lime
#property indicator_color5 Gray
#property indicator_color6 Gray

extern color zhengdang = Gray;
int Gi_unused_80 = -1;
int G_width_84 = 8;
double G_ibuf_88[];
double G_ibuf_92[];
double G_ibuf_96[];
double G_ibuf_100[];
double G_ibuf_104[];
double G_ibuf_108[];
int Gi_unused_112 = 0;
int Gi_unused_116 = 0;
string Gs_120 = "MHDMT_XMA";
string Gs_128 = "MHDMT_GRAY_BELT";

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   string Ls_unused_0;
   IndicatorBuffers(6);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, G_ibuf_88);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, G_ibuf_92);
   SetIndexStyle(2, DRAW_LINE, STYLE_DASH);
   SetIndexBuffer(2, G_ibuf_96);
   SetIndexStyle(3, DRAW_LINE, STYLE_DASH);
   SetIndexBuffer(3, G_ibuf_100);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, G_ibuf_104);
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, G_ibuf_108);
   IndicatorShortName("MHDMT_ZT");
   SetIndexLabel(0, "ZD");
   SetIndexLabel(1, "ZK");
   SetIndexLabel(2, "KS");
   SetIndexLabel(3, "DS");
   SetIndexLabel(4, "GBH");
   SetIndexLabel(5, "GBL");
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   ObjectsDeleteAll(WindowOnDropped());
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   double Ld_0;
   double Ld_8;
   bool Li_16;
   bool Li_20;
   int ind_counted_28 = IndicatorCounted();
   ObjectsDeleteAll(WindowOnDropped());
   int Li_32 = WindowFirstVisibleBar();
   int highest_36 = iHighest(NULL, 0, MODE_HIGH, WindowBarsPerChart(), WindowFirstVisibleBar() - WindowBarsPerChart() + 1);
   double Ld_40 = (WindowPriceMax() - WindowPriceMin()) / 15.0;
   int window_48 = WindowOnDropped();
   ObjectDelete("duoqujian");
   ObjectCreate("duoqujian", OBJ_TEXT, 0, Time[Li_32 / 2], High[highest_36]);
   ObjectSetText("duoqujian", "【红色多头区间：只做多,不做空】", 16, "黑体", Maroon);
   ObjectDelete("kongqujian");
   ObjectCreate("kongqujian", OBJ_TEXT, 0, Time[Li_32 / 2], High[highest_36] - Ld_40);
   ObjectSetText("kongqujian", "【绿色空头区间：只做空,不做多】", 16, "黑体", DarkGreen);
   ObjectDelete("zhendangqujian");
   ObjectCreate("zhendangqujian", OBJ_TEXT, 0, Time[Li_32 / 2], High[highest_36] - 2.0 * Ld_40);
   ObjectSetText("zhendangqujian", "【震荡区间：多空双向操作】", 16, "黑体", zhengdang);
   for (int Li_52 = Li_32; Li_52 >= 0; Li_52--) {
      Li_16 = FALSE;
      Li_20 = FALSE;
      G_ibuf_88[Li_52] = 2.0 * iCustom(NULL, 0, Gs_120, 25, 25, 3, 1, Li_52) - iCustom(NULL, 0, Gs_120, 25, 25, 2, 1, Li_52);
      G_ibuf_92[Li_52] = 2.0 * iCustom(NULL, 0, Gs_120, 25, 25, 2, 1, Li_52) - iCustom(NULL, 0, Gs_120, 25, 25, 3, 1, Li_52);
      G_ibuf_96[Li_52] = 3.0 * (iCustom(NULL, 0, Gs_120, 61, 61, 2, 1, Li_52) - iCustom(NULL, 0, Gs_120, 61, 61, 3, 1, Li_52)) + iCustom(NULL, 0, Gs_120, 61, 61, 2, 1,
         Li_52);
      G_ibuf_100[Li_52] = iCustom(NULL, 0, Gs_120, 61, 61, 3, 1, Li_52) - 3.0 * (iCustom(NULL, 0, Gs_120, 61, 61, 2, 1, Li_52) - iCustom(NULL, 0, Gs_120, 61, 61, 3, 1,
         Li_52));
      G_ibuf_104[Li_52] = iCustom(NULL, 0, Gs_128, 2, Li_52);
      G_ibuf_108[Li_52] = iCustom(NULL, 0, Gs_128, 3, Li_52);
      Ld_0 = iCustom(NULL, 0, Gs_128, 2, Li_52) + 2.0 * iCustom(NULL, 0, Gs_128, 4, Li_52);
      Ld_8 = iCustom(NULL, 0, Gs_128, 3, Li_52) - 2.0 * iCustom(NULL, 0, Gs_128, 4, Li_52);
      ObjectCreate("Graybelt" + DoubleToStr(Time[Li_52], 0), OBJ_TREND, window_48, Time[Li_52], G_ibuf_104[Li_52], Time[Li_52], G_ibuf_108[Li_52]);
      ObjectSet("Graybelt" + DoubleToStr(Time[Li_52], 0), OBJPROP_COLOR, C'0x55,0x55,0x55');
      ObjectSet("Graybelt" + DoubleToStr(Time[Li_52], 0), OBJPROP_RAY, FALSE);
      ObjectSet("Graybelt" + DoubleToStr(Time[Li_52], 0), OBJPROP_WIDTH, G_width_84);
      ObjectSet("Graybelt" + DoubleToStr(Time[Li_52], 0), OBJPROP_BACK, TRUE);
      if (G_ibuf_92[Li_52] > Ld_0 && G_ibuf_88[Li_52] > Ld_8) {
         ObjectCreate("duo" + DoubleToStr(Time[Li_52], 0), OBJ_TREND, window_48, Time[Li_52], G_ibuf_88[Li_52], Time[Li_52], G_ibuf_92[Li_52]);
         ObjectSet("duo" + DoubleToStr(Time[Li_52], 0), OBJPROP_COLOR, Maroon);
         ObjectSet("duo" + DoubleToStr(Time[Li_52], 0), OBJPROP_RAY, FALSE);
         ObjectSet("duo" + DoubleToStr(Time[Li_52], 0), OBJPROP_WIDTH, G_width_84);
         ObjectSet("duo" + DoubleToStr(Time[Li_52], 0), OBJPROP_BACK, TRUE);
      }
      if (G_ibuf_92[Li_52] < Ld_0 && G_ibuf_88[Li_52] < Ld_8) {
         ObjectCreate("dong" + DoubleToStr(Time[Li_52], 0), OBJ_TREND, window_48, Time[Li_52], G_ibuf_92[Li_52], Time[Li_52], G_ibuf_88[Li_52]);
         ObjectSet("dong" + DoubleToStr(Time[Li_52], 0), OBJPROP_COLOR, DarkGreen);
         ObjectSet("dong" + DoubleToStr(Time[Li_52], 0), OBJPROP_RAY, FALSE);
         ObjectSet("dong" + DoubleToStr(Time[Li_52], 0), OBJPROP_WIDTH, G_width_84);
         ObjectSet("dong" + DoubleToStr(Time[Li_52], 0), OBJPROP_BACK, TRUE);
      }
      if (G_ibuf_92[Li_52] < Ld_0 && G_ibuf_88[Li_52] > Ld_8) {
         ObjectCreate("dang" + DoubleToStr(Time[Li_52], 0), OBJ_TREND, window_48, Time[Li_52], G_ibuf_88[Li_52], Time[Li_52], G_ibuf_92[Li_52]);
         ObjectSet("dang" + DoubleToStr(Time[Li_52], 0), OBJPROP_COLOR, zhengdang);
         ObjectSet("dang" + DoubleToStr(Time[Li_52], 0), OBJPROP_RAY, FALSE);
         ObjectSet("dang" + DoubleToStr(Time[Li_52], 0), OBJPROP_WIDTH, G_width_84);
         ObjectSet("dang" + DoubleToStr(Time[Li_52], 0), OBJPROP_BACK, TRUE);
      }
      if (G_ibuf_88[Li_52 + 1] < Low[Li_52 + 1] && G_ibuf_88[Li_52] > Low[Li_52] && (G_ibuf_92[Li_52] > Ld_0 && G_ibuf_88[Li_52] > Ld_8) || (G_ibuf_92[Li_52] < Ld_0 && G_ibuf_88[Li_52] > Ld_8)) {
         ObjectCreate("duosong" + DoubleToStr(Time[Li_52], 0), OBJ_TEXT, 0, Time[Li_52], iCustom(NULL, 0, Gs_120, 25, 25, 3, 1, Li_52) - 3.9 * (iCustom(NULL, 0, Gs_120, 25,
            25, 2, 1, Li_52) - iCustom(NULL, 0, Gs_120, 25, 25, 3, 1, Li_52)));
         ObjectSetText("duosong" + DoubleToStr(Time[Li_52], 0), "损", 16, "黑体", Red);
         ObjectCreate("zuoduo" + DoubleToStr(Time[Li_52], 0), OBJ_TEXT, 0, Time[Li_52], Low[Li_52]);
         ObjectSetText("zuoduo" + DoubleToStr(Time[Li_52], 0), "多", 16, "黑体", Red);
         Li_16 = TRUE;
      }
      if (High[Li_52 + 1] < G_ibuf_92[Li_52 + 1] && High[Li_52] > G_ibuf_92[Li_52] && (G_ibuf_92[Li_52] < Ld_0 && G_ibuf_88[Li_52] < Ld_8) || (G_ibuf_92[Li_52] < Ld_0 &&
         G_ibuf_88[Li_52] > Ld_8)) {
         ObjectCreate("kongsong" + DoubleToStr(Time[Li_52], 0), OBJ_TEXT, 0, Time[Li_52], 3.9 * (iCustom(NULL, 0, Gs_120, 25, 25, 2, 1, Li_52) - iCustom(NULL, 0, Gs_120, 25,
            25, 3, 1, Li_52)) + iCustom(NULL, 0, Gs_120, 25, 25, 2, 1, Li_52));
         ObjectSetText("kongsong" + DoubleToStr(Time[Li_52], 0), "损", 16, "黑体", Lime);
         ObjectCreate("zuokong" + DoubleToStr(Time[Li_52], 0), OBJ_TEXT, 0, Time[Li_52], High[Li_52]);
         ObjectSetText("zuokong" + DoubleToStr(Time[Li_52], 0), "空", 16, "黑体", Lime);
         Li_20 = TRUE;
      }
      if (G_ibuf_88[Li_52 + 1] < Low[Li_52 + 1] && G_ibuf_88[Li_52] > Low[Li_52] && (G_ibuf_92[Li_52] < Ld_0 && G_ibuf_88[Li_52] < Ld_8) || (!G_ibuf_92[Li_52] < Ld_0 && G_ibuf_88[Li_52] > Ld_8) &&
         Li_16 == FALSE) {
         ObjectCreate("kongping" + DoubleToStr(Time[Li_52], 0), OBJ_TEXT, 0, Time[Li_52], Low[Li_52]);
         ObjectSetText("kongping" + DoubleToStr(Time[Li_52], 0), "平", 16, "黑体", Yellow);
      }
      if (High[Li_52 + 1] < G_ibuf_92[Li_52 + 1] && High[Li_52] > G_ibuf_92[Li_52] && (G_ibuf_92[Li_52] > Ld_0 && G_ibuf_88[Li_52] > Ld_8) || (!G_ibuf_92[Li_52] < Ld_0 &&
         G_ibuf_88[Li_52] > Ld_8) && Li_20 == FALSE) {
         ObjectCreate("duoping" + DoubleToStr(Time[Li_52], 0), OBJ_TEXT, 0, Time[Li_52], High[Li_52]);
         ObjectSetText("duoping" + DoubleToStr(Time[Li_52], 0), "平", 16, "黑体", Yellow);
      }
   }
   ObjectDelete("zhiying1");
   ObjectCreate("zhiying1", OBJ_TEXT, 0, Time[0] + (Time[1] - Time[2]) * 2, G_ibuf_88[0]);
   ObjectSetText("zhiying1", DoubleToStr(G_ibuf_88[0], 4), 8, "Times New Roman", White);
   ObjectDelete("zhiying2");
   ObjectCreate("zhiying2", OBJ_TEXT, 0, Time[0] + (Time[1] - Time[2]) * 2, G_ibuf_92[0]);
   ObjectSetText("zhiying2", DoubleToStr(G_ibuf_92[0], 4), 8, "Times New Roman", White);
   ObjectDelete("zhisong1");
   double price_56 = 3.0 * (iCustom(NULL, 0, Gs_120, 61, 61, 2, 1, 0) - iCustom(NULL, 0, Gs_120, 61, 61, 3, 1, 0)) + iCustom(NULL, 0, Gs_120, 61, 61, 2, 1, 0);
   ObjectCreate("zhisong1", OBJ_TEXT, 0, Time[0] + (Time[1] - Time[2]) * 2, price_56);
   ObjectSetText("zhisong1", DoubleToStr(price_56, 4), 8, "Times New Roman", Red);
   ObjectDelete("zhisong2");
   double price_64 = iCustom(NULL, 0, Gs_120, 61, 61, 3, 1, 0) - 3.0 * (iCustom(NULL, 0, Gs_120, 61, 61, 2, 1, 0) - iCustom(NULL, 0, Gs_120, 61, 61, 3, 1, 0));
   ObjectCreate("zhisong2", OBJ_TEXT, 0, Time[0] + (Time[1] - Time[2]) * 2, price_64);
   ObjectSetText("zhisong2", DoubleToStr(G_ibuf_100[0], 4), 8, "Times New Roman", Lime);
   return (0);
}
