/*
   Generated by EX4-TO-MQ4 decompiler ONE FILE V4.0.218.3
   EX4 ID : 04E20A41724C2645BAEB3FDF008C44EC
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2008, albarag Corp."
#property link      "LastDream555@hotmail.com"

#property indicator_chart_window

extern int Corner = 1;
extern int minBars = 5;
extern int maxBars = 21;
extern bool IsTRIANGLE = TRUE;
extern bool IsHiding = FALSE;
extern int NumberOfPattrens = 1;
string gs_unused_100 = "Genral Setting...";
double gd_108 = 0.05;
double gd_116 = 0.2;
int gi_124 = 0;
int gi_128 = 0;
int gi_132 = 0;
int gi_136 = 5;
int gi_140 = 0;
bool gi_144 = FALSE;
int gi_unused_148 = 2139610;
int g_count_152 = 0;
string gs_unused_156 = "Gartley Setting...";
bool gi_164 = TRUE;
int g_color_168 = Indigo;
string gs_unused_172 = "Gartley Setting...";
bool gi_180 = FALSE;
bool gi_unused_184 = FALSE;
string gs_unused_188 = "Gartley Setting...";
bool gi_196 = FALSE;
int g_color_200 = DeepPink;
string gs_unused_204 = "Gartley Setting...";
bool gi_212 = FALSE;
int gi_unused_216 = 16748574;
bool gi_220 = FALSE;
bool gi_224 = FALSE;
int g_color_228 = Blue;
int g_color_232 = DarkGreen;
int g_window_236 = 0;
int gi_unused_240 = 0;
double gd_unused_244 = 0.0;
int gi_unused_252;
string gs_unused_256 = "";
string gs_unused_264 = "";
string gs_unused_272 = "";
string gs_unused_280 = "";
string gs_unused_288 = "";
string gs_unused_296 = "";
string gs_unused_304 = "";
string gs_unused_312 = "";
string gs_unused_320 = "";
string g_time2str_328 = "";
bool gi_336 = TRUE;
string gs_340 = "";
string gs_348 = "";
int gi_356 = 10;
int gi_360 = 5;
int gi_364 = 20;
int gi_unused_368 = 37;
int gi_372 = 15;
int g_count_376 = 0;
int gi_380 = 0;
int g_x_384;
double g_ibuf_388[];
string gs_392 = "LastDream_Patterns";
int gi_400;
int gi_404;
int gi_408;
int gi_412;
int gi_416;
int gi_420;
int gi_424;
int gi_428;
int gi_432;
int gi_436;
int gi_440;
int gi_444;
int gi_448;
int gi_452;
int gi_456;
int gi_460;
int gi_464;
int gi_468;
int gi_472;

int ChechAcc() {
   int li_0 = 2020;
   int li_unused_4 = 333;
   bool li_ret_8 = FALSE;
   if (Year() <= li_0) li_ret_8 = TRUE;
   else li_ret_8 = FALSE;
   return (li_ret_8);
}

int init() {
   IndicatorBuffers(1);
   SetIndexBuffer(0, g_ibuf_388);
   SetIndexEmptyValue(0, 0.0);
   IndicatorShortName(gs_392);
   gi_124 = minBars;
   gi_128 = maxBars;
   return (0);
}

int deinit() {
   DeleteObject();
   return (0);
}

int DeleteObject() {
   string lsa_0[7] = {"Gartley", "Butterfly", "Crab", "Bat", "Pattern_5-0", "AB=CD", "WolfeWaves"};
   for (int l_index_4 = 0; l_index_4 < 7; l_index_4++) {
      for (int l_count_8 = 0; l_count_8 <= gi_128; l_count_8++) {
         ObjectDelete("Dream1_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("Dream2_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("Dream3_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamTargetC_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamTextTargetC_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamMinTargetD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamTextMinTargetD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamMaxTargetD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamTextMaxTargetD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamRetXB_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamTextRetXB_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamRetAC_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamTextRetAC_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamPriceMinTargetC_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamPriceMinTargetD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamPriceMaxTargetD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamXX_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamAA_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamBB_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamCC_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamDD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("DreamDD_" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib000" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib000_label" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib100" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib100_label" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib1618" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib1618_label" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib2618" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib2618_label" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib4236" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete("fib4236_label" + lsa_0[l_index_4] + l_count_8);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 1);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 2);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 3);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 4);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 5);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 6);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 7);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 8);
         ObjectDelete(lsa_0[l_index_4] + l_count_8 + 20);
      }
   }
   ObjectDelete("NOPatterns");
   ObjectDelete("NOPatterns1");
   return (0);
}

int start() {
   int lia_0[];
   int l_index_4;
   int l_index_8;
   int li_16;
   int li_20;
   int li_24;
   int li_28;
   int li_32;
   int li_36;
   if (!ChechAcc()) {
      Alert("Mail To  LastDream555@hotmail.com Thank You");
      return (0);
   }
   if (IsHiding) {
      Commentar("The Pattrens Is Hiding");
      return (0);
   }
   gi_336 = TRUE;
   Comment("");
   g_count_152 = 0;
   g_count_376 = 0;
   gi_380 = 0;
   g_x_384 = gi_360;
   DeleteObject();
   if (gi_144 == TRUE) g_time2str_328 = TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS);
   if (gi_132 != 0) {
      gi_124 = gi_132;
      gi_128 = gi_132;
   }
   for (int li_12 = gi_124; li_12 <= gi_128; li_12++) {
      li_36 = gi_140;
      if (li_36 == 0) ZZTalex(li_12);
      else ZZTalex(li_12);
      ArrayResize(lia_0, gi_136);
      if (gi_140 == 0) {
         l_index_4 = 0;
         l_index_8 = 0;
         while (l_index_4 < Bars - 1 && l_index_8 <= gi_136) {
            if (g_ibuf_388[l_index_4] != 0.0) {
               lia_0[l_index_8] = l_index_4;
               l_index_8++;
            }
            l_index_4++;
         }
      }
      if (gi_164) {
         li_16 = lia_0[gi_136 - 1];
         li_20 = lia_0[gi_136 - 2];
         li_24 = lia_0[gi_136 - 3];
         li_28 = lia_0[gi_136 - 4];
         li_32 = lia_0[gi_136 - 5];
         if (NumberOfPattrens > g_count_152) GartleyPatternsSearch(li_16, li_20, li_24, li_28, li_32, li_12);
      }
      if (gi_180) {
         li_16 = lia_0[gi_136 - 1];
         li_20 = lia_0[gi_136 - 2];
         li_24 = lia_0[gi_136 - 3];
         li_28 = lia_0[gi_136 - 4];
         li_32 = lia_0[gi_136 - 5];
         Patterns50Search(li_16, li_20, li_24, li_28, li_32, li_12);
      }
      if (gi_196) {
         li_20 = lia_0[gi_136 - 2];
         li_24 = lia_0[gi_136 - 3];
         li_28 = lia_0[gi_136 - 4];
         li_32 = lia_0[gi_136 - 5];
         ABCDSearch(li_20, li_24, li_28, li_32, li_12);
      }
      if (gi_212) {
         li_16 = lia_0[gi_136 - 1];
         li_20 = lia_0[gi_136 - 2];
         li_24 = lia_0[gi_136 - 3];
         li_28 = lia_0[gi_136 - 4];
         li_32 = lia_0[gi_136 - 5];
         WolfWavesSearch(li_16, li_20, li_24, li_28, li_32, li_12);
      }
   }
   if (gi_336) {
      gs_348 = "No Patterns Found on this Time Frame ";
      gs_348 = gs_348 
      + "\nhttp://www.arabictrader.com/vb";
   } else gs_348 = "";
   CorrectObject();
   Commentar(gs_348);
   return (0);
}

void GartleyPatternsSearch(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16, int ai_20) {
   double ld_144;
   double ld_160;
   double ld_240;
   double ld_248;
   double ld_256;
   double ld_264;
   double ld_272;
   double ld_280;
   double ld_288;
   double ld_24 = 0.382;
   double ld_unused_32 = 0.5;
   double ld_40 = 0.618;
   double ld_48 = 0.786;
   double ld_56 = 0.886;
   double ld_64 = 1.128;
   double ld_unused_72 = 1.236;
   double ld_80 = 1.272;
   double ld_88 = 1.618;
   double ld_96 = 2.236;
   double ld_104 = 2.618;
   double ld_112 = 3.618;
   string ls_184 = "";
   string ls_192 = "";
   string ls_200 = "";
   if (gi_400 == ai_0 && gi_404 == ai_4 && gi_408 == ai_8 && gi_412 == ai_12 && gi_416 == ai_16) return;
   gi_400 = ai_0;
   gi_404 = ai_4;
   gi_408 = ai_8;
   gi_412 = ai_12;
   gi_416 = ai_16;
   double ld_168 = 1 - gd_108;
   double ld_176 = gd_108 + 1.0;
   int li_224 = ai_4;
   int li_228 = ai_8;
   int li_232 = ai_12;
   int li_236 = ai_16;
   if (g_ibuf_388[li_232] < g_ibuf_388[li_228] && g_ibuf_388[li_232] > g_ibuf_388[li_224] && g_ibuf_388[li_236] < g_ibuf_388[li_228] && g_ibuf_388[li_236] > g_ibuf_388[li_232]) {
      ls_184 = "Bullish";
      ls_200 = "Max";
   }
   if (g_ibuf_388[li_232] > g_ibuf_388[li_228] && g_ibuf_388[li_232] < g_ibuf_388[li_224] && g_ibuf_388[li_236] > g_ibuf_388[li_228] && g_ibuf_388[li_236] < g_ibuf_388[li_232]) {
      ls_184 = "Bearish";
      ls_200 = "Min";
   }
   if (ls_184 != "") {
      ld_144 = (g_ibuf_388[li_228] - g_ibuf_388[li_232]) / (g_ibuf_388[li_228] - g_ibuf_388[li_224] + 0.000001);
      ld_160 = (g_ibuf_388[li_236] - g_ibuf_388[li_232]) / (g_ibuf_388[li_228] - g_ibuf_388[li_232] + 0.000001);
      if (ld_144 >= ld_24 * ld_168 && ld_144 <= ld_40 * ld_176 && ld_160 >= ld_24 * ld_168 && ld_160 <= ld_56 * ld_176) {
         ls_192 = "Gartley";
         g_color_168 = Indigo;
         ld_240 = g_ibuf_388[li_236] - ld_64 * ld_168 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_248 = g_ibuf_388[li_236] - ld_96 * ld_176 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_256 = g_ibuf_388[li_228] - ld_40 * ld_168 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_264 = g_ibuf_388[li_228] - ld_48 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_288 = 0.886 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_232]) + g_ibuf_388[li_232];
         if (ls_184 == "Bullish") {
            if (ld_240 < ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 > ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         if (ls_184 == "Bearish") {
            if (ld_240 > ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 < ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         CreateFuturePattern(li_224, li_228, li_232, li_236, ai_20, ld_272, ld_280, ld_288, ld_144, ld_160, ls_184, ls_192, ls_200);
         return;
      }
      if (ld_144 >= ld_40 * ld_168 && ld_144 <= ld_56 * ld_176 && ld_160 >= ld_24 * ld_168 && ld_160 <= ld_56 * ld_176) {
         ls_192 = "Butterfly";
         g_color_168 = DarkSlateGray;
         ld_240 = g_ibuf_388[li_236] - ld_80 * ld_168 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_248 = g_ibuf_388[li_236] - ld_104 * ld_176 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_256 = g_ibuf_388[li_228] - ld_80 * ld_168 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_264 = g_ibuf_388[li_228] - ld_88 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_288 = 0.886 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_232]) + g_ibuf_388[li_232];
         if (ls_184 == "Bullish") {
            if (ld_240 < ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 > ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         if (ls_184 == "Bearish") {
            if (ld_240 > ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 < ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         CreateFuturePattern(li_224, li_228, li_232, li_236, ai_20, ld_272, ld_280, ld_288, ld_144, ld_160, ls_184, ls_192, ls_200);
         return;
      }
      if (ld_144 >= ld_24 * ld_168 && ld_144 <= ld_56 * ld_176 && ld_160 >= ld_24 * ld_168 && ld_160 <= ld_56 * ld_176) {
         ls_192 = "Crab";
         g_color_168 = DarkGreen;
         ld_240 = g_ibuf_388[li_236] - ld_88 * ld_168 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_248 = g_ibuf_388[li_236] - ld_112 * ld_176 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_256 = g_ibuf_388[li_228] - ld_88 * ld_168 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_264 = g_ibuf_388[li_228] - ld_88 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_288 = 0.886 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_232]) + g_ibuf_388[li_232];
         if (ls_184 == "Bullish") {
            if (ld_240 < ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 > ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         if (ls_184 == "Bearish") {
            if (ld_240 > ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 < ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         CreateFuturePattern(li_224, li_228, li_232, li_236, ai_20, ld_272, ld_280, ld_288, ld_144, ld_160, ls_184, ls_192, ls_200);
         return;
      }
      if (ld_144 >= ld_24 * ld_168 && ld_144 <= ld_40 * ld_176 && ld_160 >= ld_24 * ld_168 && ld_160 <= ld_56 * ld_176) {
         ls_192 = "Bat";
         g_color_168 = RoyalBlue;
         ld_240 = g_ibuf_388[li_236] - ld_80 * ld_168 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_248 = g_ibuf_388[li_236] - ld_104 * ld_176 * (g_ibuf_388[li_236] - g_ibuf_388[li_232]);
         ld_256 = g_ibuf_388[li_228] - ld_56 * ld_168 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_264 = g_ibuf_388[li_228] - ld_56 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_224]);
         ld_288 = 0.886 * ld_176 * (g_ibuf_388[li_228] - g_ibuf_388[li_232]) + g_ibuf_388[li_232];
         if (ls_184 == "Bullish") {
            if (ld_240 < ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 > ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         if (ls_184 == "Bearish") {
            if (ld_240 > ld_256) ld_272 = ld_240;
            else ld_272 = ld_256;
            if (ld_248 < ld_264) ld_280 = ld_248;
            else ld_280 = ld_264;
         }
         CreateFuturePattern(li_224, li_228, li_232, li_236, ai_20, ld_272, ld_280, ld_288, ld_144, ld_160, ls_184, ls_192, ls_200);
      }
   }
}

void Harmonic_Data(string a_name_0, string a_text_8, int ai_unused_16, int ai_20, int ai_unused_24 = 0) {
   ObjectCreate(a_name_0, OBJ_LABEL, g_window_236, 0, 0);
   ObjectSetText(a_name_0, a_text_8, 8, "Arial Bold", Snow);
   ObjectSet(a_name_0, OBJPROP_CORNER, Corner);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, g_x_384);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, gi_364 + ai_20);
}

void CreateFuturePattern(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16, double ad_20, double ad_28, double a_price_36, double ad_unused_44, double ad_unused_52, string as_60, string as_68, string as_unused_76) {
   int l_datetime_84;
   double l_price_120;
   double l_price_128;
   double l_price_136;
   double l_price_144;
   double l_price_152;
   double ld_unused_104 = 0.0;
   double l_price_112 = 0.0;
   string ls_160 = "";
   string ls_168 = as_68 + "_" + as_60 + "_" + ai_16;
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 1, "----------------------------------", 55295, gi_380);
   g_count_376++;
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 2, ls_168, g_color_168, gi_380);
   g_count_376++;
   double ld_88 = 1 - gd_108;
   double ld_96 = gd_108 + 1.0;
   if (ai_8 << 1 - ai_0 >= 0) l_datetime_84 = Time[ai_8 << 1 - ai_0];
   else l_datetime_84 = Time[0] - 60 * ((ai_8 << 1 - ai_0) * Period());
   if (as_68 == "Pattern_5-0" || as_68 == "AB=CD") {
      ObjectDelete("Dream3_" + as_68 + ai_16 + g_time2str_328);
      ObjectCreate("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, Time[ai_4], g_ibuf_388[ai_4], Time[ai_8], g_ibuf_388[ai_8], Time[ai_12], a_price_36);
      ObjectSet("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJPROP_WIDTH, 2);
      ObjectSet("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJPROP_BACK, IsTRIANGLE);
      ObjectSet("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_168);
      ObjectSetText("Dream3_" + as_68 + ai_16 + g_time2str_328, as_68 + "_" + as_60 + "_" + TimeFrame() + "_" + ai_16);
      if (ai_12 - (ai_4 - ai_8) >= 0) l_datetime_84 = Time[ai_12 - (ai_4 - ai_8)];
      else l_datetime_84 = Time[0] - 60 * ((ai_12 - (ai_4 - ai_8)) * Period());
   }
   if (as_68 != "AB=CD") {
      ObjectDelete("Dream1_" + as_68 + ai_16 + g_time2str_328);
      ObjectCreate("Dream1_" + as_68 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, Time[ai_0], g_ibuf_388[ai_0], Time[ai_4], g_ibuf_388[ai_4], Time[ai_8], g_ibuf_388[ai_8]);
      ObjectSet("Dream1_" + as_68 + ai_16 + g_time2str_328, OBJPROP_WIDTH, 2);
      ObjectSet("Dream1_" + as_68 + ai_16 + g_time2str_328, OBJPROP_BACK, IsTRIANGLE);
      ObjectSet("Dream1_" + as_68 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_168);
      ObjectSetText("Dream1_" + as_68 + ai_16 + g_time2str_328, as_68 + "_" + as_60 + "_" + TimeFrame() + "_" + ai_16);
   }
   ObjectDelete("Dream2_" + as_68 + ai_16 + g_time2str_328);
   ObjectCreate("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, Time[ai_8], g_ibuf_388[ai_8], Time[ai_12], a_price_36, l_datetime_84, (ad_20 + ad_28) / 2.0);
   ObjectSet("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJPROP_WIDTH, 2);
   ObjectSet("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJPROP_BACK, IsTRIANGLE);
   ObjectSet("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_168);
   ObjectSetText("Dream2_" + as_68 + ai_16 + g_time2str_328, as_68 + "_" + as_60 + "_" + TimeFrame() + "_" + ai_16);
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 3, "----------------------------------", 55295, gi_380);
   g_count_376++;
   if (as_60 == "Bullish") {
      ls_160 = "Sell Order ";
      ls_168 = "StopLose     = " + DoubleToStr(g_ibuf_388[ai_4] + 20.0 * Point, Digits) 
      + "\n";
      l_price_120 = g_ibuf_388[ai_0] - gi_356 * Point;
      l_price_128 = g_ibuf_388[ai_4] + gi_356 * Point;
      l_price_136 = g_ibuf_388[ai_8] - gi_356 * Point;
      l_price_144 = a_price_36 + gi_356 * Point;
      l_price_152 = (ad_20 + ad_28) / 2.0 - gi_356 * Point;
      l_price_112 = a_price_36;
   }
   if (as_60 == "Bearish") {
      ls_160 = "Buy Order ";
      ls_168 = "StopLose     = " + DoubleToStr(g_ibuf_388[ai_4] - 20.0 * Point, Digits) 
      + "\n";
      l_price_120 = g_ibuf_388[ai_0] + gi_356 * Point;
      l_price_128 = g_ibuf_388[ai_4] - gi_356 * Point;
      l_price_136 = g_ibuf_388[ai_8] + gi_356 * Point;
      l_price_144 = a_price_36 - gi_356 * Point;
      l_price_152 = (ad_20 + ad_28) / 2.0 + gi_356 * Point;
      l_price_112 = a_price_36;
   }
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 4, ls_168, g_color_168, gi_380);
   g_count_376++;
   ls_168 = ls_160 + "   = " + DoubleToStr(l_price_112, Digits);
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 5, ls_168, g_color_168, gi_380);
   g_count_376++;
   ls_168 = "Target D 1    = " + DoubleToStr(g_ibuf_388[ai_8], Digits);
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 6, ls_168, g_color_168, gi_380);
   g_count_376++;
   ls_168 = "Target D 2    = " + DoubleToStr(ad_20, Digits);
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 7, ls_168, g_color_168, gi_380);
   g_count_376++;
   ls_168 = "Target D 3    = " + DoubleToStr(ad_28, Digits);
   gi_380 = gi_372 * g_count_376;
   Harmonic_Data(as_68 + ai_16 + 8, ls_168, g_color_168, gi_380);
   g_count_376++;
   ObjectCreate("DreamXX_" + as_68 + ai_16 + g_time2str_328, OBJ_TEXT, 0, Time[ai_0], l_price_120);
   ObjectSetText("DreamXX_" + as_68 + ai_16 + g_time2str_328, "X", 12, "Arial Bold", Gold);
   ObjectCreate("DreamAA_" + as_68 + ai_16 + g_time2str_328, OBJ_TEXT, 0, Time[ai_4], l_price_128);
   ObjectSetText("DreamAA_" + as_68 + ai_16 + g_time2str_328, "A", 12, "Arial Bold", Gold);
   ObjectCreate("DreamBB_" + as_68 + ai_16 + g_time2str_328, OBJ_TEXT, 0, Time[ai_8], l_price_136);
   ObjectSetText("DreamBB_" + as_68 + ai_16 + g_time2str_328, "B", 12, "Arial Bold", Gold);
   ObjectCreate("DreamCC_" + as_68 + ai_16 + g_time2str_328, OBJ_TEXT, 0, Time[ai_12], l_price_144);
   ObjectSetText("DreamCC_" + as_68 + ai_16 + g_time2str_328, "C", 12, "Arial Bold", Gold);
   ObjectCreate("DreamDD_" + as_68 + ai_16 + g_time2str_328, OBJ_TEXT, 0, l_datetime_84, l_price_152);
   ObjectSetText("DreamDD_" + as_68 + ai_16 + g_time2str_328, "D", 12, "Arial Bold", Gold);
   gi_336 = FALSE;
   g_count_152++;
   g_count_376 = 0;
   gi_380 = 0;
   g_x_384 += 120;
}

void CreateFutureABCD(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16, double ad_20, double ad_28, double ad_36, double ad_44, double ad_52, string as_60, string as_68, string as_76) {
   int l_datetime_84;
   double ld_unused_104 = 0.0;
   gs_340 = gs_340 + "====== " + as_68 + "_" + ai_16 + " ======" 
   + "\n";
   double ld_88 = 1 - gd_108;
   double ld_96 = gd_108 + 1.0;
   if (ai_8 << 1 - ai_0 >= 0) l_datetime_84 = Time[ai_8 << 1 - ai_0];
   else l_datetime_84 = Time[0] - 60 * ((ai_8 << 1 - ai_0) * Period());
   ObjectDelete("Dream3_" + as_68 + ai_16 + g_time2str_328);
   ObjectCreate("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, Time[ai_4], g_ibuf_388[ai_4], Time[ai_8], g_ibuf_388[ai_8], Time[ai_12], g_ibuf_388[ai_12]);
   ObjectSet("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_200);
   ObjectSet("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJPROP_WIDTH, 2);
   ObjectSet("Dream3_" + as_68 + ai_16 + g_time2str_328, OBJPROP_BACK, FALSE);
   ObjectSetText("Dream3_" + as_68 + ai_16 + g_time2str_328, as_68 + "_" + as_60 + "_" + TimeFrame() + "_" + ai_16);
   if (ai_12 - (ai_4 - ai_8) >= 0) l_datetime_84 = Time[ai_12 - (ai_4 - ai_8)];
   else l_datetime_84 = Time[0] - 60 * ((ai_12 - (ai_4 - ai_8)) * Period());
   ObjectDelete("Dream2_" + as_68 + ai_16 + g_time2str_328);
   ObjectCreate("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, Time[ai_8], g_ibuf_388[ai_8], Time[ai_12], g_ibuf_388[ai_12], l_datetime_84, (ad_20 + ad_28) / 2.0);
   ObjectSet("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_200);
   ObjectSet("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJPROP_WIDTH, 2);
   ObjectSet("Dream2_" + as_68 + ai_16 + g_time2str_328, OBJPROP_BACK, FALSE);
   ObjectSetText("Dream2_" + as_68 + ai_16 + g_time2str_328, as_68 + "_" + as_60 + "_" + TimeFrame() + "_" + ai_16);
   gs_340 = gs_340 + as_76 + "Target C = " + DoubleToStr(ad_36, Digits) 
   + "\n";
   gs_340 = gs_340 + "Target D 1    = " + DoubleToStr(ad_20, Digits) 
   + "\n";
   gs_340 = gs_340 + "Target D 2    = " + DoubleToStr(ad_28, Digits) 
   + "\n";
   ld_unused_104 = 0.0;
   string ls_152 = DoubleToStr(ad_44, 3) + ExtRet(ad_44, ld_88, ld_96);
   string ls_160 = DoubleToStr(ad_52, 3) + ExtRet(ad_52, ld_88, ld_96);
   ObjectDelete("DreamRetAC_" + as_68 + ai_16 + g_time2str_328);
   ObjectCreate("DreamRetAC_" + as_68 + ai_16 + g_time2str_328, OBJ_TREND, 0, Time[ai_4], g_ibuf_388[ai_4], Time[ai_12], g_ibuf_388[ai_12]);
   ObjectSet("DreamRetAC_" + as_68 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_200);
   ObjectSet("DreamRetAC_" + as_68 + ai_16 + g_time2str_328, OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("DreamRetAC_" + as_68 + ai_16 + g_time2str_328, OBJPROP_RAY, FALSE);
   ld_unused_104 = 0.0;
}

void Patterns50Search(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16, int ai_20) {
   double ld_92;
   double ld_108;
   double ld_172;
   double ld_180;
   double ld_188;
   double ld_196;
   double ld_204;
   double ld_24 = 0.5;
   double ld_32 = 1.128;
   double ld_unused_40 = 1.236;
   double ld_unused_48 = 1.272;
   double ld_56 = 1.618;
   double ld_64 = 2.236;
   string ls_132 = "";
   string ls_140 = "";
   string ls_148 = "";
   if (gi_420 == ai_0 && gi_424 == ai_4 && gi_428 == ai_8 && gi_432 == ai_12 && gi_436 == ai_16) return;
   gi_420 = ai_0;
   gi_424 = ai_4;
   gi_428 = ai_8;
   gi_432 = ai_12;
   gi_436 = ai_16;
   double ld_116 = 1 - gd_108;
   double ld_124 = gd_108 + 1.0;
   int li_156 = ai_4;
   int li_160 = ai_8;
   int li_164 = ai_12;
   int li_168 = ai_16;
   if (g_ibuf_388[li_156] < g_ibuf_388[li_160] && g_ibuf_388[li_156] > g_ibuf_388[li_164] && g_ibuf_388[li_160] < g_ibuf_388[li_168]) {
      ls_132 = "Bullish";
      ls_148 = "Max";
   }
   if (g_ibuf_388[li_156] > g_ibuf_388[li_160] && g_ibuf_388[li_156] < g_ibuf_388[li_164] && g_ibuf_388[li_160] > g_ibuf_388[li_168]) {
      ls_132 = "Bearish";
      ls_148 = "Min";
   }
   if (ls_132 != "") {
      ld_92 = (g_ibuf_388[li_160] - g_ibuf_388[li_164]) / (g_ibuf_388[li_160] - g_ibuf_388[li_156] + 0.000001);
      ld_108 = (g_ibuf_388[li_168] - g_ibuf_388[li_164]) / (g_ibuf_388[li_160] - g_ibuf_388[li_164] + 0.000001);
      if (ld_92 >= ld_32 * ld_116 && ld_92 <= ld_56 * ld_124 && ld_108 >= ld_56 * ld_116 && ld_108 <= ld_64 * ld_124) {
         ls_140 = "Pattern_5-0";
         ld_172 = g_ibuf_388[li_168] - ld_24 * ld_116 * (g_ibuf_388[li_168] - g_ibuf_388[li_164]);
         ld_180 = g_ibuf_388[li_168] - ld_24 * ld_124 * (g_ibuf_388[li_168] - g_ibuf_388[li_164]);
         ld_204 = 2.236 * ld_124 * (g_ibuf_388[li_160] - g_ibuf_388[li_164]) + g_ibuf_388[li_164];
         if (ls_132 == "Bearish") {
            ld_188 = ld_180;
            ld_196 = ld_172;
         }
         if (ls_132 == "Bullish") {
            ld_188 = ld_172;
            ld_196 = ld_180;
         }
         CreateFuturePattern(li_156, li_160, li_164, li_168, ai_20, ld_188, ld_196, ld_204, ld_92, ld_108, ls_132, ls_140, ls_148);
      }
   }
}

void ABCDSearch(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16) {
   double ld_72;
   double ld_80;
   int li_136;
   double ld_152;
   double ld_160;
   double ld_168;
   double ld_176;
   double ld_184;
   double ld_20 = 0.618;
   double ld_28 = 0.786;
   double ld_unused_36 = 1.272;
   double ld_unused_44 = 1.618;
   string ls_112 = "";
   string ls_120 = "";
   string ls_128 = "";
   if (gi_440 == ai_0 && gi_444 == ai_4 && gi_448 == ai_8 && gi_452 == ai_12) return;
   gi_440 = ai_0;
   gi_444 = ai_4;
   gi_448 = ai_8;
   gi_452 = ai_12;
   double ld_96 = 1 - gd_108;
   double ld_104 = gd_108 + 1.0;
   int li_140 = ai_4;
   int li_144 = ai_8;
   int li_148 = ai_12;
   if (g_ibuf_388[li_140] > g_ibuf_388[li_148] && g_ibuf_388[li_148] > g_ibuf_388[li_144]) {
      ls_112 = "Bullish";
      ls_128 = "Max";
   }
   if (g_ibuf_388[li_140] < g_ibuf_388[li_148] && g_ibuf_388[li_148] < g_ibuf_388[li_144]) {
      ls_112 = "Bearish";
      ls_128 = "Min";
   }
   if (ls_112 != "") {
      ld_72 = (g_ibuf_388[li_148] - g_ibuf_388[li_144]) / (g_ibuf_388[li_140] - g_ibuf_388[li_144] + 0.000001);
      if (ld_72 >= ld_20 * ld_96 && ld_72 <= ld_28 * ld_104) {
         ls_120 = "AB=CD";
         ld_152 = g_ibuf_388[li_148] - ld_96 * (g_ibuf_388[li_140] - g_ibuf_388[li_144]);
         ld_160 = g_ibuf_388[li_148] - ld_104 * (g_ibuf_388[li_140] - g_ibuf_388[li_144]);
         ld_184 = 0.786 * ld_104 * (g_ibuf_388[li_140] - g_ibuf_388[li_144]) + g_ibuf_388[li_144];
         if (ls_112 == "Bearish") {
            ld_168 = ld_160;
            ld_176 = ld_152;
         }
         if (ls_112 == "Bullish") {
            ld_168 = ld_152;
            ld_176 = ld_160;
         }
         CreateFutureABCD(li_136, li_140, li_144, li_148, ai_16, ld_168, ld_176, ld_184, ld_80, ld_72, ls_112, ls_120, ls_128);
      }
   }
}

void WolfWavesSearch(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16, int ai_20) {
   datetime l_time_24;
   datetime l_time_28;
   datetime l_time_32;
   datetime l_time_36;
   int li_40;
   int li_44;
   int li_48;
   int li_52;
   int li_56;
   double ld_60;
   double ld_68;
   double ld_76;
   double ld_84;
   double ld_92;
   double ld_100;
   double ld_108;
   double ld_116;
   double ld_124;
   string ls_148 = "";
   string ls_156 = "";
   if (gi_456 == ai_0 && gi_460 == ai_4 && gi_464 == ai_8 && gi_468 == ai_12 && gi_472 == ai_16) return;
   gi_456 = ai_0;
   gi_460 = ai_4;
   gi_464 = ai_8;
   gi_468 = ai_12;
   gi_472 = ai_16;
   ai_0 = ai_4;
   ai_4 = ai_8;
   ai_8 = ai_12;
   ai_12 = ai_16;
   ai_16 = 0;
   if (g_ibuf_388[ai_0] < g_ibuf_388[ai_4] && g_ibuf_388[ai_0] > g_ibuf_388[ai_8] && g_ibuf_388[ai_12] < g_ibuf_388[ai_4] && g_ibuf_388[ai_12] > g_ibuf_388[ai_0] && (ai_0 - ai_8) / (1.0 * (ai_4 - ai_12)) <= gd_116 +
      1.0 && (ai_0 - ai_8) / (1.0 * (ai_4 - ai_12)) >= 1 - gd_116) ls_148 = "Bull";
   if (g_ibuf_388[ai_0] > g_ibuf_388[ai_4] && g_ibuf_388[ai_0] < g_ibuf_388[ai_8] && g_ibuf_388[ai_12] > g_ibuf_388[ai_4] && g_ibuf_388[ai_12] < g_ibuf_388[ai_0] && (ai_0 - ai_8) / (1.0 * (ai_4 - ai_12)) <= gd_116 +
      1.0 && (ai_0 - ai_8) / (1.0 * (ai_4 - ai_12)) >= 1 - gd_116) ls_148 = "Bear";
   if (ls_148 != "") {
      l_time_24 = Time[ai_0];
      ld_60 = g_ibuf_388[ai_0];
      l_time_28 = Time[ai_4];
      ld_68 = g_ibuf_388[ai_4];
      l_time_32 = Time[ai_8];
      ld_76 = g_ibuf_388[ai_8];
      l_time_36 = Time[ai_12];
      ld_84 = g_ibuf_388[ai_12];
      if (ai_8 << 1 - ai_0 >= 0) li_40 = Time[ai_8 << 1 - ai_0];
      else li_40 = Time[0] - 60 * ((ai_8 << 1 - ai_0) * Period());
      ld_92 = 2.0 * ld_76 - ld_60;
      if (ld_84 < ld_92) {
         li_44 = li_40;
         ld_100 = ld_92;
         li_48 = li_40;
         ld_108 = g_ibuf_388[ai_8] - NormalizeDouble((g_ibuf_388[ai_4] - g_ibuf_388[ai_12]) / (ai_4 - ai_12) * (ai_0 - ai_8), Digits);
         li_52 = Time[0] - 60 * ((ai_12 << 1 - ai_0) * Period());
         ld_116 = 2.0 * g_ibuf_388[ai_12] - g_ibuf_388[ai_0];
         li_56 = li_52 + 60 * ((ai_0 - ai_8) * Period());
         ld_124 = ld_116 - (g_ibuf_388[ai_0] - g_ibuf_388[ai_8]);
         ls_156 = "WolfeWaves";
         WolfWavesDraw(ls_156, ls_148, ai_20, l_time_24, l_time_28, l_time_32, l_time_36, li_40, li_44, li_48, li_52, li_56, ld_60, ld_68, ld_76, ld_84, ld_92, ld_100, ld_108, ld_116, ld_124);
      }
   }
}

void WolfWavesDraw(string as_0, string as_8, int ai_16, int a_datetime_20, int a_datetime_24, int a_datetime_28, int a_datetime_32, int ai_unused_36, int a_datetime_40, int a_datetime_44, int a_datetime_48, int a_datetime_52, double a_price_56, double a_price_64, double a_price_72, double a_price_80, double ad_unused_88, double a_price_96, double a_price_104, double a_price_112, double a_price_120) {
   ObjectCreate("RealRetXB_" + as_0 + ai_16 + g_time2str_328, OBJ_TREND, 0, a_datetime_20, a_price_56, a_datetime_40, a_price_96);
   ObjectSet("RealRetXB_" + as_0 + ai_16 + g_time2str_328, OBJPROP_COLOR, Fuchsia);
   ObjectSet("RealRetXB_" + as_0 + ai_16 + g_time2str_328, OBJPROP_RAY, FALSE);
   ObjectCreate("RealRetXD_" + as_0 + ai_16 + g_time2str_328, OBJ_TREND, 0, a_datetime_20, a_price_56, a_datetime_48, a_price_112);
   ObjectSet("RealRetXD_" + as_0 + ai_16 + g_time2str_328, OBJPROP_COLOR, Red);
   ObjectSet("RealRetXD_" + as_0 + ai_16 + g_time2str_328, OBJPROP_RAY, FALSE);
   ObjectCreate("RealRetAC_" + as_0 + ai_16 + g_time2str_328, OBJ_TREND, 0, a_datetime_24, a_price_64, a_datetime_32, a_price_80);
   ObjectSet("RealRetAC_" + as_0 + ai_16 + g_time2str_328, OBJPROP_COLOR, Aqua);
   ObjectSet("RealRetAC_" + as_0 + ai_16 + g_time2str_328, OBJPROP_RAY, FALSE);
   if (gi_220) {
      ObjectCreate("Real1_" + as_0 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, a_datetime_28, a_price_72, a_datetime_40, a_price_96, a_datetime_44, a_price_104);
      ObjectSet("Real1_" + as_0 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_228);
      ObjectSetText("Real1_" + as_0 + ai_16 + g_time2str_328, as_0 + "-" + as_8 + "_" + TimeFrame() + "_" + ai_16);
   }
   if (gi_224) {
      ObjectCreate("Real2_" + as_0 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, a_datetime_20, a_price_56, a_datetime_28, a_price_72, a_datetime_48, a_price_112);
      ObjectCreate("Real3_" + as_0 + ai_16 + g_time2str_328, OBJ_TRIANGLE, 0, a_datetime_28, a_price_72, a_datetime_48, a_price_112, a_datetime_52, a_price_120);
      ObjectSet("Real2_" + as_0 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_232);
      ObjectSet("Real3_" + as_0 + ai_16 + g_time2str_328, OBJPROP_COLOR, g_color_232);
      ObjectSetText("Real2_" + as_0 + ai_16 + g_time2str_328, as_0 + "-" + as_8 + "_" + TimeFrame() + "_" + ai_16);
      ObjectSetText("Real3_" + as_0 + ai_16 + g_time2str_328, as_0 + "-" + as_8 + "_" + TimeFrame() + "_" + ai_16);
   }
}

void CorrectObject() {
   string l_name_0;
   string l_name_8;
   for (int li_16 = 0; li_16 < ObjectsTotal(); li_16++) {
      l_name_0 = ObjectName(li_16);
      for (int li_20 = 0; li_20 < ObjectsTotal(); li_20++) {
         l_name_8 = ObjectName(li_20);
         if (l_name_0 != l_name_8) {
            if (ObjectType(l_name_0) == 17 && ObjectType(l_name_8) == 17) {
               if (ObjectGet(l_name_0, OBJPROP_TIME1) == ObjectGet(l_name_8, OBJPROP_TIME1) && ObjectGet(l_name_0, OBJPROP_TIME2) == ObjectGet(l_name_8, OBJPROP_TIME2) && ObjectGet(l_name_0, OBJPROP_TIME3) == ObjectGet(l_name_8, OBJPROP_TIME3) &&
                  ObjectGet(l_name_0, OBJPROP_PRICE1) == ObjectGet(l_name_8, OBJPROP_PRICE1) && ObjectGet(l_name_0, OBJPROP_PRICE2) == ObjectGet(l_name_8, OBJPROP_PRICE2) && ObjectGet(l_name_0, OBJPROP_PRICE3) == ObjectGet(l_name_8, OBJPROP_PRICE3)) ObjectDelete(l_name_8);
            }
         }
      }
   }
}

void ZZTalex(int ai_0) {
   int li_24;
   int l_highest_28;
   int li_32;
   int lia_40[];
   double ld_44;
   double lda_52[];
   bool li_56;
   bool li_60;
   for (int li_4 = 0; li_4 <= Bars - 1; li_4++) g_ibuf_388[li_4] = 0.0;
   int li_36 = gi_136;
   int l_lowest_16 = iLowest(NULL, 0, MODE_LOW, ai_0, 0);
   int l_highest_20 = iHighest(NULL, 0, MODE_HIGH, ai_0, 0);
   if (l_lowest_16 < l_highest_20) {
      li_24 = l_lowest_16;
      ld_44 = Low[l_lowest_16];
   }
   if (l_lowest_16 > l_highest_20) {
      li_24 = l_highest_20;
      ld_44 = High[l_highest_20];
   }
   if (l_lowest_16 == l_highest_20) {
      li_24 = l_lowest_16;
      ld_44 = funk1(l_lowest_16, ai_0);
   }
   ArrayResize(lia_40, gi_136);
   ArrayResize(lda_52, gi_136);
   int l_index_8 = 0;
   gd_unused_244 = ld_44;
   gi_unused_240 = li_24;
   lia_40[l_index_8] = li_24;
   lda_52[l_index_8] = ld_44;
   li_36--;
   if (ld_44 == Low[li_24]) li_56 = TRUE;
   else li_56 = FALSE;
   gi_unused_252 = li_56;
   li_4 = li_24 + 1;
   while (li_36 > 0) {
      if (li_56) {
         while (li_4 <= Bars - 1) {
            l_highest_28 = iHighest(NULL, 0, MODE_HIGH, ai_0, li_4);
            li_32 = iHighest(NULL, 0, MODE_HIGH, ai_0, l_highest_28);
            if (l_highest_28 == li_32) {
               li_24 = l_highest_28;
               ld_44 = High[li_24];
               li_56 = FALSE;
               li_4 = li_24 + 1;
               l_index_8++;
               break;
            }
            li_4 = li_32;
         }
         lia_40[l_index_8] = li_24;
         lda_52[l_index_8] = ld_44;
         li_36--;
      }
      if (li_36 == 0) break;
      if (!li_56) {
         while (li_4 <= Bars - 1) {
            l_highest_28 = iLowest(NULL, 0, MODE_LOW, ai_0, li_4);
            li_32 = iLowest(NULL, 0, MODE_LOW, ai_0, l_highest_28);
            if (l_highest_28 == li_32) {
               li_24 = l_highest_28;
               ld_44 = Low[li_24];
               li_56 = TRUE;
               li_4 = li_24 + 1;
               l_index_8++;
               break;
            }
            li_4 = li_32;
         }
         lia_40[l_index_8] = li_24;
         lda_52[l_index_8] = ld_44;
         li_36--;
      }
   }
   if (lda_52[0] == Low[lia_40[0]]) li_60 = TRUE;
   else li_60 = FALSE;
   for (int l_index_12 = 0; l_index_12 <= gi_136 - 1; l_index_12++) {
      if (l_index_12 == 0) {
         if (li_60 == TRUE) {
            lia_40[l_index_12] = iLowest(NULL, 0, MODE_LOW, lia_40[l_index_12 + 1] - lia_40[l_index_12], lia_40[l_index_12]);
            lda_52[l_index_12] = Low[lia_40[l_index_12]];
            gi_unused_240 = gi_132;
         }
         if (li_60 == FALSE) {
            lia_40[l_index_12] = iHighest(NULL, 0, MODE_HIGH, lia_40[l_index_12 + 1] - lia_40[l_index_12], lia_40[l_index_12]);
            lda_52[l_index_12] = High[lia_40[l_index_12]];
            gi_unused_240 = gi_132;
         }
      }
      if (l_index_12 < gi_136 - 2) {
         if (li_60 == TRUE) {
            lia_40[l_index_12 + 1] = iHighest(NULL, 0, MODE_HIGH, lia_40[l_index_12 + 2] - lia_40[l_index_12] - 1, lia_40[l_index_12] + 1);
            lda_52[l_index_12 + 1] = High[lia_40[l_index_12 + 1]];
         }
         if (li_60 == FALSE) {
            lia_40[l_index_12 + 1] = iLowest(NULL, 0, MODE_LOW, lia_40[l_index_12 + 2] - lia_40[l_index_12] - 1, lia_40[l_index_12] + 1);
            lda_52[l_index_12 + 1] = Low[lia_40[l_index_12 + 1]];
         }
      }
      if (li_60 == TRUE) li_60 = FALSE;
      else li_60 = TRUE;
      g_ibuf_388[lia_40[l_index_12]] = lda_52[l_index_12];
   }
}

double funk1(int ai_0, int ai_4) {
   double ld_ret_8;
   int l_lowest_16 = iLowest(NULL, 0, MODE_LOW, ai_4, ai_0);
   int l_highest_20 = iHighest(NULL, 0, MODE_HIGH, ai_4, ai_0);
   if (l_lowest_16 > l_highest_20) ld_ret_8 = High[ai_0];
   if (l_lowest_16 < l_highest_20) ld_ret_8 = Low[ai_0];
   if (l_lowest_16 == l_highest_20) {
      l_lowest_16 = iLowest(NULL, 0, MODE_LOW, ai_4 << 1, ai_0);
      l_highest_20 = iHighest(NULL, 0, MODE_HIGH, ai_4 << 1, ai_0);
      if (l_lowest_16 > l_highest_20) ld_ret_8 = High[ai_0];
      if (l_lowest_16 < l_highest_20) ld_ret_8 = Low[ai_0];
      if (l_lowest_16 == l_highest_20) {
         l_lowest_16 = iLowest(NULL, 0, MODE_LOW, 3 * ai_4, ai_0);
         l_highest_20 = iHighest(NULL, 0, MODE_HIGH, 3 * ai_4, ai_0);
         if (l_lowest_16 > l_highest_20) ld_ret_8 = High[ai_0];
         if (l_lowest_16 < l_highest_20) ld_ret_8 = Low[ai_0];
      }
   }
   return (ld_ret_8);
}

string TimeFrame() {
   string ls_unused_0;
   switch (Period()) {
   case PERIOD_M1:
      return ("M1");
   case PERIOD_M5:
      return ("M5");
   case PERIOD_M15:
      return ("M15");
   case PERIOD_M30:
      return ("M30");
   case PERIOD_H1:
      return ("H1");
   case PERIOD_H4:
      return ("H4");
   case PERIOD_D1:
      return ("D1");
   case PERIOD_W1:
      return ("W1");
   case PERIOD_MN1:
      return ("MN1");
   }
   return ("");
}

void Commentar(string as_0) {
   Comment("LastDream Patterns", 
   "\n", as_0);
}

string ExtRet(double ad_0, double ad_8, double ad_16) {
   double ld_24;
   string ls_ret_32 = "";
   string ls_40 = "";
   bool li_48 = TRUE;
   if (ad_0 >= ad_8 / 2.0 && ad_0 <= ad_16 / 2.0) {
      ld_24 = 100.0 * (ad_0 / 0.382 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "0.382" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= ad_8 / 2.0 && ad_0 <= ad_16 / 2.0) {
      ld_24 = 100.0 * (ad_0 / 0.5 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "0.5" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 0.618 * ad_8 && ad_0 <= 0.618 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 0.618 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "0.618" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 0.707 * ad_8 && ad_0 <= 0.707 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 0.707 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "0.707" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 0.786 * ad_8 && ad_0 <= 0.786 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 0.786 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "0.786" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 0.886 * ad_8 && ad_0 <= 0.886 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 0.886 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "0.886" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 1.128 * ad_8 && ad_0 <= 1.128 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 1.128 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "1.128" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 1.236 * ad_8 && ad_0 <= 1.236 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 1.236 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "1.236" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 1.272 * ad_8 && ad_0 <= 1.272 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 1.272 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "1.272" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 1.414 * ad_8 && ad_0 <= 1.414 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 1.414 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "1.414" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 1.618 * ad_8 && ad_0 <= 1.618 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 1.618 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "1.618" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 2.236 * ad_8 && ad_0 <= 2.236 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 2.236 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "2.236" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 2.618 * ad_8 && ad_0 <= 2.618 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 2.618 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "2.618" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (ad_0 >= 3.618 * ad_8 && ad_0 <= 3.618 * ad_16) {
      ld_24 = 100.0 * (ad_0 / 3.618 - 1.0);
      if (ld_24 >= 0.0) ls_40 = "+";
      else ls_40 = "-";
      li_48 = FALSE;
      ls_ret_32 = " (" + "3.618" + ls_40 + DoubleToStr(MathAbs(ld_24), 2) + "%" + ")";
   }
   if (li_48) ls_ret_32 = " (n/a)";
   return (ls_ret_32);
}