Navigation´╝ÜHome > Content >

Korharmony-OpenSource_V1.0.mq4

Time: 2013-02-14 | Download file:Korharmony-OpenSource_V1.0.mq4

#property copyright "Original & Final Release of Korharmony - Poland, Europe -  OpenSource Version 1.0"
#property link      "N/A"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Black
#property indicator_color3 Black

#import "user32.dll"
   int GetWindowDC(int a0);
   int ReleaseDC(int a0, int a1);
   bool GetWindowRect(int a0, int& a1[]);
   int GetClientRect(int a0, int& a1[]);
#import "gdi32.dll"
   int GetPixel(int a0, int a1, int a2);
#import

string gsa_76[50000][2];
string gsa_80[50000][2];
string gsa_84[50000][2];
string gsa_unused_88[50000][2];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
int g_index_104;
int g_index_108;
int g_index_112;
int gi_unused_120 = 0;
double gd_124 = 0.0;
double gd_132 = 0.0;
double gd_140 = 0.0;
double gd_148 = 0.0;
int gi_unused_156 = 50;
string gsa_160[30] = {"ABCD", "I ABCD", "I+T ABCD", "Gartley", "Butterfly", "Crab", "Bat", "SHS", "3Drives", "5-0", "One2One", "E One2One", "S One2One", "Triangle", "Diagonal", "Fibo382", "Fibo500", "Fibo618", "Fibo786", "Fibo886"};
int gia_164[30];
extern string separator1 = "************************ Main Params ***";
extern int iextRefreshRate = 4;
extern int iextMaxBars = 5000;
extern int iextHL_MinSwing = 0;
int gi_188 = 5;
int gi_192 = 150;
extern int iextMaxZZPointsUsed = 9;
extern bool bextShowHistoryPatterns = FALSE;
extern bool bextCheckMultiZigzags = TRUE;
extern double dextHL_MultiZZMinSwingRange = 0.4;
extern int iextHL_MultiZZMinSwingNum = 10;
extern string separator2 = "************************ Calculation deltas ***";
extern double dextMaxDeviation = 0.1;
extern double dextFiboDeviation = 0.03;
extern double dextMaxSHSPriceDeviation = 0.3;
extern double dextMaxSHSTimeDeviation = 0.3;
extern double dextMaxCorrDeviation = 0.1;
extern double dextMaxOne2OneDeviation = 0.1;
extern double dextMaxTriangleDeviation = 0.05;
extern string separator3 = "************************ What to draw ***";
extern bool bextDrawZZLine = FALSE;
extern bool bextDrawZZRelations = FALSE;
extern bool bextDrawZZPoints = FALSE;
extern bool bextDrawProjectionLines = TRUE;
extern bool bextDrawRelationLines = FALSE;
extern bool bextDrawPatternDim = FALSE;
extern bool bextDrawDetailedPatternDim = FALSE;
extern bool bextDrawPatternDescr = FALSE;
extern bool bextDrawRectangle = FALSE;
extern bool bextDrawPRZ = TRUE;
extern int iextDescrFontSize = 14;
extern string separator4 = "******************** Patterns ON/OFF ***";
extern bool bextFibo = TRUE;
extern bool bextFibo382 = TRUE;
extern bool bextFibo500 = TRUE;
extern bool bextFibo618 = TRUE;
extern bool bextFibo786 = TRUE;
extern bool bextFibo886 = TRUE;
extern string FiboLevelsStr = "0.236; 0.382; 0.500; 0.618; 0.707; 0.786; 0.862; 0.886; 1.00; 1.127; 1.382; 1.414; 1.618; 2.236; 2.618; 3.142; 3.618; 4.236; 5.00;";
double gda_376[30];
int gi_380;
extern string FiboExtRetLevelsStr = "1.13; 1.272; 1.500; 1.618; 1.912; 2.000; 2.058; 2.236; 2.618; 3.618; 4.236; ";
double gda_392[30];
int gi_396;
extern string FiboIntRetLevelsStr = "0.146; 0.186; 0.236; 0.300; 0.382; 0.447; 0.486; 0.500; 0.564; 0.618; 0.685; 0.786; 0.886; 1.00; ";
double gda_408[30];
int gi_412;
extern string FiboProjLevelsStr = "0.236; 0.382; 0.500; 0.618; 0.786; 1.000; 1.272; 1.500; 1.618; 2.00; 2.236; 2.618; 4.236; ";
double gda_424[30];
int gi_428;
extern string FiboAPPProjLevelsStr = "0.500; 0.618; 0.685; 0.786; 0.886; 1.000; 1.130; 1.272; 1.500; 1.618; 2.00; 2.236; 2.618; 3.618; 4.236; ";
double gda_440[30];
int gi_444;
extern bool bextABCD = TRUE;
extern bool bextI_ABCD = TRUE;
extern bool bextIT_ABCD = TRUE;
extern bool bextWXY = FALSE;
extern bool bextGartley = TRUE;
extern bool bextIdealGartleyOnly = FALSE;
extern bool bextButterfly = TRUE;
extern bool bextIdealButterflyOnly = FALSE;
extern bool bextCrab = TRUE;
extern bool bextIdealCrabOnly = FALSE;
extern bool bextBat = TRUE;
extern bool bextIdealBatOnly = FALSE;
extern bool bextBatman = FALSE;
extern bool bextSHS = FALSE;
extern bool bextI_SHS = TRUE;
extern bool bext3Drives = TRUE;
extern bool bext5_0 = TRUE;
extern bool bextEmergingPatterns = FALSE;
extern double dextEmergingPatternPerc = 0.7;
bool gi_528 = FALSE;
extern bool bextOne2One = TRUE;
extern bool bextEOne2One = TRUE;
extern bool bextSOne2One = TRUE;
extern bool bextOne2OneFibo = FALSE;
bool gi_548 = FALSE;
bool gi_552 = FALSE;
bool gi_556 = FALSE;
bool gi_560 = FALSE;
bool gi_564 = FALSE;
double gd_568 = 100.0;
double gd_576 = 0.5;
double gd_584 = 100.0;
double gd_592 = 0.5;
double gda_600[8];
double gda_604[8];
int gi_608 = 255;
int gi_612 = 16711680;
int gi_616 = 65535;
int gi_620 = 16777215;
extern string separator5 = "*********************** Alerts ON/OFF ***";
extern bool bextMT4AlertON = TRUE;
extern bool bextMT4EmailON = FALSE;
extern bool bextAlertInvalidatedPatterns = FALSE;
extern string separator6 = "***************** Sound Alarms ON/OFF ***";
extern bool bextSoundAlertON = TRUE;
extern string sextInfoPatternSoundFile = "news.wav";
extern string separator7 = "***************** Save as GIF ON/OFF ***";
extern bool bextScreenshotPatternsON = FALSE;
extern string sextSaveImageDestinationDir = "korHarmonics/";
extern string separator8 = "***************** Signal Monitoring ON/OFF ***";
extern bool bextSigMonitonitoringON = TRUE;
extern string sextSigMonitoringDir = "korSigMon/";
extern string separator8a = "***************** Signal Web Monitoring ON/OFF ***";
extern bool bextSigWebMonitonitoringON = FALSE;
extern string sextSigWebMonitoringDir = "korSigWebMon/";
extern string separator9 = "************************ Patterns colors ***";
extern color cextFiboDescColor = Blue;
extern color cextABCDBullishColor = Blue;
extern color cextABCDBearishColor = DeepPink;
extern color cextABCDDescColor = Blue;
extern color cextWXYColor = Pink;
extern color cextGartleyBullishColor = SeaGreen;
extern color cextGartleyBearishColor = C'0xDD,0x00,0x2D';
extern color cextGartleyDescColor = Blue;
extern color cextButterflyBullishColor = Green;
extern color cextButterflyBearishColor = Red;
extern color cextButterflyDescColor = Blue;
extern color cextCrabBullishColor = GreenYellow;
extern color cextCrabBearishColor = C'0xEC,0x51,0x78';
extern color cextCrabDescColor = Blue;
extern color cextBatBullishColor = DarkGreen;
extern color cextBatBearishColor = C'0x80,0x00,0x0A';
extern color cextBatDescColor = Blue;
extern color cextBatmanBullishColor = White;
extern color cextBatmanBearishColor = White;
extern color cextBatmanDescColor = Blue;
extern color cextSHSBullishColor = Pink;
extern color cextSHSBearishColor = Pink;
extern color cextSHSDescColor = Red;
extern color cext3Drives1BullishColor = C'0x00,0x00,0x64';
extern color cext3Drives2BullishColor = C'0x2F,0x00,0x51';
extern color cext3Drives1BearishColor = C'0x7D,0x00,0x00';
extern color cext3Drives2BearishColor = C'0x48,0x00,0x00';
extern color cext3DrivesDescColor = Red;
extern color cext5_0BullishColor = MediumSpringGreen;
extern color cext5_0BearishColor = Red;
extern color cext5_0DescColor = Red;
extern color cextCorrBullishColor = LimeGreen;
extern color cextCorrBearishColor = Salmon;
extern color cextCorrDescColor = Red;
extern color cextTriangleBullishColor = DimGray;
extern color cextTriangleBearishColor = Tomato;
extern color cextITriangleBullishColor = DarkSlateBlue;
extern color cextITriangleBearishColor = Crimson;
extern color cextNITriangleBullishColor = Blue;
extern color cextNITriangleBearishColor = Red;
extern color cextTriangleDescColor = White;
extern color cextDiagonalColor = White;
extern color cextDiagonalDescColor = White;
extern color cextEmergingBullishColor = Yellow;
extern color cextEmergingBearishColor = DarkOrange;
extern color cextOne2OneBullishColor = Salmon;
extern color cextOne2OneCorrBullishColor = Red;
extern color cextOne2OneBearishColor = Salmon;
extern color cextOne2OneCorrBearishColor = Red;
extern color cextSOne2OneCorrBullishColor = Brown;
extern color cextSOne2OneCorrBearishColor = Brown;
int gi_936 = 16776960;
int gi_940 = 3937500;
extern color cextRectangleColor = Orange;
extern color cextPatternDimColor = Yellow;
int gi_952 = 3;
int gi_956 = 3;
int gi_960 = 3;
int gi_964 = 5;
int gi_968 = 1;
int gi_972 = 5;
int gi_976 = 3;
int gi_980 = 1;
int gi_984 = 4;
int gi_988 = 3;
extern string separator10 = "************************ ZZ lines colors ***";
extern color cextZZLineColor = DarkViolet;
extern color cextZZRelLineColor = Indigo;
extern string separator11 = "************************ Other Colors ***";
extern color extBackgroundColor = Black;
extern color extTextColor = White;
extern color cextRelationLine = C'0x15,0x22,0x22';
extern string separator12 = "************************ MinSwing defaults file ***";
extern string sextMinSwingDefaultsFile = "korHarmonics/korHarmonics_MinSwingDefaults.txt";
int gia_unused_1044[100];
int gia_unused_1048[100];
int gia_1052[90];
int gia_1056[90];
string gsa_1060[90][2] = {"No pattern", "No pattern",
   "ABCD Bullish", "ABCDBu",
   "ABCD Bearish", "ABCDBe",
   "I+ABCD Bullish", "IABCDBu",
   "I+ABCD Bearish", "IABCDBe",
   "I+T+ABCD Bullish", "ITABCDBu",
   "I+T+ABCD Bearish", "ITABCDBe",
   "Gartley Bullish", "GaBu",
   "Gartley Bearish", "GaBe",
   "Butterfly Bullish", "BuBu",
   "Butterfly Bearish", "BuBe",
   "Crab Bullish", "CrBu",
   "Crab Bearish", "CrBe",
   "Bat Bullish", "BaBu",
   "Bat Bearish", "BaBe",
   "Emerging Gartley Bullish", "EmGaBu",
   "Emerging Gartley Bearish", "EmGaBe",
   "Emerging Butterfly Bullish", "EmBuBu",
   "Emerging Butterfly Bearish", "EmBuBe",
   "Emerging Crab Bullish", "EmCrBu",
   "Emerging Crab Bearish", "EmCrBe",
   "Emerging Bat Bullish", "EmBaBu",
   "Emerging Bat Bearish", "EmBaBe",
   "3Drives Bullish", "3DBu",
   "3Drives Bearish", "3DBe",
   "5-0 Bullish", "50Bu",
   "5-0 Bearish", "50Be",
   "Batman Bullish", "BnBu",
   "Batman Bearish", "BnBe",
   "SHS Bullish", "SHSBu",
   "SHS Bearish", "SHSBe",
   "I+SHS Bullish", "ISHSBu",
   "I+SHS Bearish", "ISHSBe",
   "One2One Bullish", "O2OBu",
   "One2One Bearish", "O2OBe",
   "Emerging One2One Bullish", "EmO2OBu",
   "Emerging One2One Bearish", "EmO2OBe",
   "EnhOne2One Bullish", "EO2OBu",
   "EnhOne2One Bearish", "EO2OBe",
   "Emerging EnhOne2One Bullish", "EmEO2OBu",
   "Emerging EnhOne2One Bearish", "EmEO2OBe",
   "S One2One Bullish", "SO2OBu",
   "S One2One Bearish", "SO2OBe",
   "Emerging S One2One Bullish", "EmSO2OBu",
   "Emerging S One2One Bearish", "EmSO2OBe",
   "Camel Run Bullish", "CaRuBu",
   "Camel Run Bearish", "CaRuBe",
   "Camel Break Bullish", "CaBrBu",
   "Camel Break Bearish", "CaBrBe",
   "Camel Flat Bullish", "CaFlBu",
   "Camel Flat Bearish", "CaFlBe",
   "Camel Unreg Bullish", "CaUnBu",
   "Camel Unreg Bearish", "CaUnBe",
   "VibrPrice+Time", "ViPT",
   "VibrPrice", "ViP",
   "VibrTime", "ViT",
   "Triangle Bullish", "TrBu",
   "Triangle Bearish", "TrBe",
   "DiaTriangle Bullish", "DiaTrBu",
   "DiaTriangle Bearish", "DiaTrBe",
   "I+Triangle", "ITrBu",
   "I+Triangle", "ITrBe",
   "NI+Triangle", "NITrBu",
   "NI+Triangle", "NITrBe",
   "WXY Bullish", "WXYBu",
   "WXY Bearish", "WXYBe",
   "Fibo Bullish", "FiboBu",
   "Fibo Bearish", "FiboBe",
   "Fibo382 Bullish", "Fibo382Bu",
   "Fibo382 Bearish", "Fibo382Be",
   "Fibo500 Bullish", "Fibo500Bu",
   "Fibo500 Bearish", "Fibo500Be",
   "Fibo618 Bullish", "Fibo618Bu",
   "Fibo618 Bearish", "Fibo618Be",
   "Fibo786 Bullish", "Fibo786Bu",
   "Fibo786 Bearish", "Fibo786Be",
   "Fibo886 Bullish", "Fibo886Bu",
   "Fibo886 Bearish", "Fibo886Be"};
string gsa_1064[300][11];
bool gi_unused_1068 = FALSE;
int g_index_1072;
int g_time_1076 = 0;
int g_datetime_1080 = 0;
int gi_1084;
bool gi_1088 = FALSE;
extern bool bextRelationAngleRotate = FALSE;

int HL_CleanArrays() {
   for (int l_index_0 = 0; l_index_0 <= 50000; l_index_0++) {
      gsa_76[l_index_0][0] = 0;
      gsa_76[l_index_0][1] = 0;
      gsa_80[l_index_0][0] = 0;
      gsa_80[l_index_0][1] = 0;
      gsa_84[l_index_0][0] = 0;
      gsa_84[l_index_0][1] = 0;
   }
   return (0);
}

void HL_Calculate(int ai_0, int ai_4, int ai_unused_8, int ai_12) {
   double l_low_40;
   double l_high_48;
   int li_56 = -1;
   gi_unused_120 = 0;
   g_index_104 = 0;
   g_index_108 = 0;
   g_index_112 = 0;
   int li_60 = ai_0;
   int li_16 = li_60;
   double l_low_24 = Low[li_60];
   int li_20 = li_60;
   double l_high_32 = High[li_60];
   DrawPriceArrow(li_16, Time[li_16], l_low_24, Lime, "Buy");
   DrawPriceArrow(li_20, Time[li_20], l_high_32, Lime, "Sell");
   for (int li_64 = li_60; li_64 >= 0; li_64--) {
      l_low_40 = Low[li_64];
      l_high_48 = High[li_64];
      if (l_high_48 - l_low_24 > ai_12 * Point && li_56 == -1 || li_56 == 1) {
         gsa_80[g_index_104][0] = TimeToStr(Time[li_16], TIME_DATE|TIME_SECONDS);
         gsa_80[g_index_104][1] = DoubleToStr(l_low_24, 4);
         g_index_104++;
         gsa_84[g_index_112][0] = TimeToStr(Time[li_16], TIME_DATE|TIME_SECONDS);
         gsa_84[g_index_112][1] = DoubleToStr(l_low_24, 4);
         g_index_112++;
         l_low_24 = l_low_40;
         li_16 = li_64;
         l_high_32 = l_high_48;
         li_20 = li_64;
         if (li_56 == -1) gi_unused_120 = 1;
         li_56 = 0;
      } else {
         if (l_high_32 - l_low_40 > ai_12 * Point && li_56 == -1 || li_56 == 0) {
            gsa_76[g_index_108][0] = TimeToStr(Time[li_20], TIME_DATE|TIME_SECONDS);
            gsa_76[g_index_108][1] = DoubleToStr(l_high_32, 4);
            g_index_108++;
            gsa_84[g_index_112][0] = TimeToStr(Time[li_20], TIME_DATE|TIME_SECONDS);
            gsa_84[g_index_112][1] = DoubleToStr(l_high_32, 4);
            g_index_112++;
            l_high_32 = l_high_48;
            li_20 = li_64;
            l_low_24 = l_low_40;
            li_16 = li_64;
            if (li_56 == -1) gi_unused_120 = -1;
            li_56 = 1;
         }
      }
      if (l_low_40 < l_low_24) {
         l_low_24 = l_low_40;
         li_16 = li_64;
      }
      if (l_high_48 > l_high_32) {
         l_high_32 = l_high_48;
         li_20 = li_64;
      }
   }
   if (li_56 == 1) {
      gsa_84[g_index_112][0] = TimeToStr(Time[li_16], TIME_DATE|TIME_SECONDS);
      gsa_84[g_index_112][1] = DoubleToStr(l_low_24, 4);
      g_index_112++;
   } else {
      if (li_56 == 0) {
         gsa_84[g_index_112][0] = TimeToStr(Time[li_20], TIME_DATE|TIME_SECONDS);
         gsa_84[g_index_112][1] = DoubleToStr(l_high_32, 4);
         g_index_112++;
      }
   }
   if (ai_4 <= g_index_112) {
   }
}

void DrawPriceArrow(int ai_0, int a_datetime_4, double a_price_8, color a_color_16, string as_20) {
   string l_name_28 = "ZZ_START_" + "arraw_" + as_20 + ai_0;
   ObjectDelete(l_name_28);
   ObjectCreate(l_name_28, OBJ_ARROW, 0, a_datetime_4, a_price_8);
   ObjectSet(l_name_28, OBJPROP_WIDTH, 5);
   if (as_20 == "Buy") ObjectSet(l_name_28, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
   else
      if (as_20 == "Sell") ObjectSet(l_name_28, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
   ObjectSet(l_name_28, OBJPROP_COLOR, a_color_16);
}

void HL_InitZZLine(color a_color_0) {
   SetIndexStyle(0, DRAW_SECTION, STYLE_SOLID, 1, a_color_0);
   SetIndexLabel(0, "ZZLine");
   SetIndexBuffer(0, g_ibuf_92);
   SetIndexEmptyValue(0, 0.0);
}

void HL_InitZZRelLine(color a_color_0) {
   SetIndexStyle(1, DRAW_SECTION, STYLE_DOT, 1, a_color_0);
   SetIndexStyle(2, DRAW_SECTION, STYLE_DOT, 1, a_color_0);
   SetIndexLabel(1, "ZZRelLine1");
   SetIndexLabel(2, "ZZRelLine2");
   SetIndexBuffer(1, g_ibuf_96);
   SetIndexBuffer(2, g_ibuf_100);
   SetIndexEmptyValue(1, 0.0);
   SetIndexEmptyValue(2, 0.0);
}

void HL_DrawZZline_ZigZag() {
   int l_shift_4;
   ArrayInitialize(g_ibuf_92, 0.0);
   for (int l_index_0 = 0; l_index_0 < g_index_112; l_index_0++) {
      l_shift_4 = iBarShift(Symbol(), Period(), StrToTime(gsa_84[l_index_0][0]));
      g_ibuf_92[l_shift_4] = StrToDouble(gsa_84[l_index_0][1]);
   }
}

void HL_DrawZZrelline_ZigZag() {
   int l_shift_4;
   ArrayInitialize(g_ibuf_96, 0.0);
   ArrayInitialize(g_ibuf_100, 0.0);
   for (int li_0 = 0; li_0 < g_index_112; li_0 += 2) {
      l_shift_4 = iBarShift(Symbol(), Period(), StrToTime(gsa_84[li_0][0]));
      g_ibuf_96[l_shift_4] = StrToDouble(gsa_84[li_0][1]);
   }
   for (li_0 = 1; li_0 < g_index_112; li_0 += 2) {
      l_shift_4 = iBarShift(Symbol(), Period(), StrToTime(gsa_84[li_0][0]));
      g_ibuf_100[l_shift_4] = StrToDouble(gsa_84[li_0][1]);
   }
}

void HL_DrawZZRelationsDesc(int ai_0, double ad_4, color a_color_12) {
   double l_str2dbl_16;
   double l_str2dbl_24;
   double l_str2dbl_32;
   int l_str2time_40;
   int l_str2time_44;
   int l_str2time_48;
   int l_shift_52;
   int l_shift_56;
   int l_shift_60;
   string l_text_64;
   string l_name_72;
   int li_80;
   double ld_84;
   string ls_96;
   for (int li_92 = g_index_112 - 2 - ai_0; li_92 < g_index_112 - 2; li_92++) {
      l_str2time_40 = StrToTime(gsa_84[li_92][0]);
      l_str2dbl_16 = StrToDouble(gsa_84[li_92][1]);
      l_str2time_44 = StrToTime(gsa_84[li_92 + 1][0]);
      l_str2dbl_24 = StrToDouble(gsa_84[li_92 + 1][1]);
      l_str2time_48 = StrToTime(gsa_84[li_92 + 2][0]);
      l_str2dbl_32 = StrToDouble(gsa_84[li_92 + 2][1]);
      l_shift_52 = iBarShift(Symbol(), Period(), l_str2time_40);
      l_shift_56 = iBarShift(Symbol(), Period(), l_str2time_44);
      l_shift_60 = iBarShift(Symbol(), Period(), l_str2time_48);
      li_80 = l_shift_52 - l_shift_60;
      if (l_str2dbl_24 - l_str2dbl_16 != 0.0) {
         ld_84 = (l_str2dbl_24 - l_str2dbl_32) / (l_str2dbl_24 - l_str2dbl_16);
         ls_96 = "";
         if (ld_84 >= (1 - ad_4) / 2.0 && ld_84 <= (ad_4 + 1.0) / 2.0) ls_96 = "38.2%";
         else {
            if (ld_84 >= (1 - ad_4) / 2.0 && ld_84 <= (ad_4 + 1.0) / 2.0) ls_96 = "50.0%";
            else {
               if (ld_84 >= 0.618 * (1 - ad_4) && ld_84 <= 0.618 * (ad_4 + 1.0)) ls_96 = "61.8%";
               else {
                  if (ld_84 >= 0.786 * (1 - ad_4) && ld_84 <= 0.786 * (ad_4 + 1.0)) ls_96 = "78.6%";
                  else {
                     if (ld_84 >= 0.886 * (1 - ad_4) && ld_84 <= 0.886 * (ad_4 + 1.0)) ls_96 = "88.6%";
                     else {
                        if (ld_84 >= 1.0 * (1 - ad_4) && ld_84 <= 1.0 * (ad_4 + 1.0)) ls_96 = "100.0%";
                        else {
                           if (ld_84 >= 1.27 * (1 - ad_4) && ld_84 <= 1.27 * (ad_4 + 1.0)) ls_96 = "127.2%";
                           else {
                              if (ld_84 >= 1.618 * (1 - ad_4) && ld_84 <= 1.618 * (ad_4 + 1.0)) ls_96 = "161.8%";
                              else {
                                 if (ld_84 >= 2.618 * (1 - ad_4) && ld_84 <= 2.618 * (ad_4 + 1.0)) ls_96 = "261.8%";
                                 else
                                    if (ld_84 >= 3.618 * (1 - ad_4) && ld_84 <= 3.618 * (ad_4 + 1.0)) ls_96 = "361.8%";
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
         l_name_72 = "HAR_O_" + "pricetime_linedesc_" + TimeToStr(l_str2time_40, TIME_DATE|TIME_MINUTES);
         ObjectDelete(l_name_72);
         ObjectCreate(l_name_72, OBJ_TEXT, 0, l_str2time_40 + (l_str2time_48 - l_str2time_40) / 3, l_str2dbl_16 + (l_str2dbl_32 - l_str2dbl_16) / 3.0, 0, 0);
         if (ls_96 != "") {
            l_text_64 = ls_96 + " , " + li_80;
            ObjectSetText(l_name_72, l_text_64, 9, "Arial", a_color_12);
         } else {
            l_text_64 = DoubleToStr(100.0 * ld_84, 1) + "% , " + li_80;
            ObjectSetText(l_name_72, l_text_64, 7, "Arial", a_color_12);
         }
      }
   }
}

void HL_DrawZZPoints(int ai_unused_0) {
   string l_name_8;
   string l_text_16;
   for (int l_index_4 = 0; l_index_4 < g_index_112; l_index_4++) {
      l_text_16 = l_index_4;
      l_name_8 = "ZZ_POINT_" + l_index_4 + "_" + gsa_84[l_index_4][0];
      ObjectDelete(l_name_8);
      ObjectCreate(l_name_8, OBJ_TEXT, 0, StrToTime(gsa_84[l_index_4][0]), StrToDouble(gsa_84[l_index_4][1]));
      ObjectSetText(l_name_8, l_text_16, 9, "Arial", White);
   }
}

string PeriodDesc(int ai_0) {
   switch (ai_0) {
   case 1:
      return ("M1");
   case 5:
      return ("M5");
   case 15:
      return ("M15");
   case 30:
      return ("M30");
   case 60:
      return ("H1");
   case 240:
      return ("H4");
   case 1440:
      return ("D1");
   case 10080:
      return ("W1");
   case 43200:
      return ("MN");
   }
   return ("Unknown Period");
}

int PeriodTimeDelta(int ai_0) {
   switch (ai_0) {
   case 1:
      return (0);
   case 5:
      return (0);
   case 15:
      return (10);
   case 30:
      return (20);
   case 60:
      return (30);
   case 240:
      return (40);
   case 1440:
      return (50);
   case 10080:
      return (60);
   case 43200:
      return (70);
   }
   return (0);
}

int InitInputFile(string a_name_0) {
   int l_file_8 = FileOpen(a_name_0, FILE_CSV|FILE_READ, ';');
   if (l_file_8 == -1 || FileSize(l_file_8) == 0) {
      Print("WARNING: File ", a_name_0, " not found, the last error is ", GetLastError());
      return (-1);
   }
   return (l_file_8);
}

int CloseFile(int a_file_0) {
   if (a_file_0 != -1) FileClose(a_file_0);
   return (0);
}

void UpdateScale() {
   gd_124 = WindowPriceMax();
   gd_132 = WindowPriceMin();
   gd_140 = gd_124 - gd_132;
   gd_148 = gd_140 / Point;
}

void ShowIndicatorInfo(string as_0, string as_8, string as_16, color a_color_24, int a_window_28, int a_corner_32) {
   string l_name_36 = as_0 + as_8;
   ObjectDelete(l_name_36);
   ObjectCreate(l_name_36, OBJ_LABEL, a_window_28, 0, 0);
   ObjectSet(l_name_36, OBJPROP_XDISTANCE, 4);
   ObjectSet(l_name_36, OBJPROP_YDISTANCE, 12);
   ObjectSet(l_name_36, OBJPROP_CORNER, a_corner_32);
   ObjectSetText(l_name_36, as_0 + " " + as_8 + as_16 + " " + "", 8, "Arial", a_color_24);
}

string DateTimeReformat(string as_0) {
   string ls_8;
   string ls_ret_16 = "";
   as_0 = " " + as_0;
   int l_str_len_24 = StringLen(as_0);
   for (int li_28 = 0; li_28 < l_str_len_24; li_28++) {
      ls_8 = StringSetChar(ls_8, 0, StringGetChar(as_0, li_28));
      if (ls_8 != ":" && ls_8 != " " && ls_8 != ".") ls_ret_16 = ls_ret_16 + ls_8;
   }
   return (ls_ret_16);
}

int DropObjects(string as_0) {
   string l_name_8;
   bool l_bool_28;
   int l_error_32;
   int l_objs_total_16 = ObjectsTotal();
   int li_24 = 0;
   for (int l_count_20 = 0; l_count_20 < l_objs_total_16; l_count_20++) {
      l_name_8 = ObjectName(li_24);
      if (StringFind(l_name_8, as_0) >= 0) {
         l_bool_28 = ObjectDelete(l_name_8);
         if (l_bool_28 == FALSE) {
            l_error_32 = GetLastError();
            Alert("ERROR,res:::::::::", l_error_32);
         }
      } else li_24++;
   }
   return (0);
}

int ParseInputString2Doubles(string as_0, double &ada_8[]) {
   int li_16;
   int l_index_20 = 0;
   int li_12 = 0;
   for (int li_24 = 0; li_24 < StringLen(as_0); li_24++) {
      if (StringGetChar(as_0, li_24) == ';') {
         li_16 = li_24;
         ada_8[l_index_20] = StrToDouble(StringSubstr(as_0, li_12, li_16 - li_12));
         l_index_20++;
         if (l_index_20 == 30) return (l_index_20);
         li_12 = li_24 + 1;
      }
   }
   return (l_index_20);
}

int WindowYPixels() {
   int lia_0[4];
   int li_4 = WindowHandle(Symbol(), Period());
   if (li_4 > 0) GetClientRect(li_4, lia_0);
   return (lia_0[3]);
}

void SIGMON_FoundPatterns_Reset() {
   for (int l_index_0 = 0; l_index_0 < 30; l_index_0++) gia_164[l_index_0] = 99;
}

void SIGMON_FoundPatterns_Set(int ai_0, int ai_4) {
   gia_164[ai_0] = ai_4;
}

void SIGMON_FoundPatterns_Save(string a_name_0) {
   string ls_12;
   int l_file_8 = FileOpen(a_name_0, FILE_CSV|FILE_WRITE, ';');
   if (l_file_8 >= 1) {
      FileWrite(l_file_8, "001;" + TimeCurrent());
      for (int l_index_20 = 0; l_index_20 < 30; l_index_20++) {
         ls_12 = l_index_20 + ";" + gia_164[l_index_20];
         FileWrite(l_file_8, ls_12);
      }
      if (l_file_8 != -1) FileClose(l_file_8);
   }
}

void SIGMON_FoundPatterns_FileDelete(string a_name_0) {
   FileDelete(a_name_0);
}

void init() {
   ShowIndicatorInfo("", " ", "", extTextColor, 0, 2);
   if (iextHL_MinSwing == 0) {
      LoadMinSwingDefaults(sextMinSwingDefaultsFile);
      iextHL_MinSwing = DefaultMinSwing();
      if (iextHL_MinSwing == -1) {
         Alert("WARNING:", "korHarmonics", ":", Symbol(), ":", PeriodDesc(Period()), ":", "Default iextHL_MinSwing values are not defined for this instrument. Please specify in the txt configuration file. Exiting...");
         return;
      }
   }
   gda_600[0] = gd_568 / 8.0;
   gda_600[1] = gd_568 / 4.0;
   gda_600[2] = gd_568 / 3.0;
   gda_600[3] = gd_568 / 2.0;
   gda_600[4] = gd_568 / 1.5;
   gda_600[5] = 0.75 * gd_568;
   gda_600[6] = 0.875 * gd_568;
   gda_600[7] = 1.0 * gd_568;
   gda_604[0] = gd_584 / 8.0;
   gda_604[1] = gd_584 / 4.0;
   gda_604[2] = gd_584 / 3.0;
   gda_604[3] = gd_584 / 2.0;
   gda_604[4] = gd_584 / 1.5;
   gda_604[5] = 0.75 * gd_584;
   gda_604[6] = 0.875 * gd_584;
   gda_604[7] = 1.0 * gd_584;
   HL_InitZZLine(cextZZLineColor);
   HL_InitZZRelLine(cextZZRelLineColor);
   if (iextMaxBars > 50000) {
      Alert("ERROR:", "korHarmonics", ":", Symbol(), ":", PeriodDesc(Period()), ":", "Specified iextMaxBars number:", iextMaxBars, " in not supported, allowed:[0,", 50000, "] ...changing to max value...");
      iextMaxBars = 50000;
   }
   if (iextMaxZZPointsUsed < 6) {
      Alert("WARNING:", "korHarmonics", ":", Symbol(), ":", PeriodDesc(Period()), ":", "Setting iextMaxZZPointsUsed to minimum =", 6, " required for harmonic analysis.");
      iextMaxZZPointsUsed = 6;
   }
   HAR_FoundPatterns_Init();
   if (bextSigMonitonitoringON == TRUE) {
      SIGMON_FoundPatterns_Reset();
      SIGMON_FoundPatterns_Save(sextSigMonitoringDir + "korHarmonicsSig" + "_" + Symbol() + "_" + PeriodDesc(Period()) + ".csv");
   }
   HL_CleanArrays();
   if (dextHL_MultiZZMinSwingRange < 0.0) {
      dextHL_MultiZZMinSwingRange = 0.0;
      Alert("WARNING:", "korHarmonics", ":", Symbol(), ":", PeriodDesc(Period()), ":", "dextHL_MultiZZMinSwingRange should be in the [0,0.9] range. Will use 0.");
   } else {
      if (dextHL_MultiZZMinSwingRange > 0.9) {
         dextHL_MultiZZMinSwingRange = 0.9;
         Alert("WARNING:", "korHarmonics", ":", Symbol(), ":", PeriodDesc(Period()), ":", "dextHL_MultiZZMinSwingRange should be in the [0,0.9] range. Will use 0.9.");
      }
   }
   gi_1084 = PeriodTimeDelta(Period());
   gi_380 = ParseInputString2Doubles(FiboLevelsStr, gda_376);
   if (bextDrawPRZ) {
      gi_412 = ParseInputString2Doubles(FiboIntRetLevelsStr, gda_408);
      gi_396 = ParseInputString2Doubles(FiboExtRetLevelsStr, gda_392);
      gi_428 = ParseInputString2Doubles(FiboProjLevelsStr, gda_424);
      gi_444 = ParseInputString2Doubles(FiboAPPProjLevelsStr, gda_440);
   }
   gi_1088 = TRUE;
}

void deinit() {
   Comment("");
   DropObjects("korHarmonics" + "6.7.9e ");
   DropObjects("ZZ_START_");
   DropObjects("ZZ_POINT_");
   DropObjects("ZZ_LINE_");
   DropObjects("HAR_O_");
   DropObjects("HAR_S_");
   if (bextSigMonitonitoringON == TRUE) SIGMON_FoundPatterns_FileDelete(sextSigMonitoringDir + "korHarmonicsSig" + "_" + Symbol() + "_" + PeriodDesc(Period()) + ".csv");
}

void start() {
   if (Time[0] > g_time_1076 || TimeCurrent() > g_datetime_1080 + iextRefreshRate) {
      g_time_1076 = Time[0];
      g_datetime_1080 = TimeCurrent();
      if (gi_1088 == TRUE) {
         if (TimeCurrent() > StrToTime("2021.01.30 00:00")) Alert("INFO:", "korHarmonics", ":", Symbol(), ":", PeriodDesc(Period()), ":", "This version has expired, please contact [email protected] to obtain newer version.");
         else {
            UpdateScale();
            HL_CleanArrays();
            HL_Calculate(iextMaxBars, iextMaxZZPointsUsed, gi_192, iextHL_MinSwing);
            HAR_FoundPatterns_ShowSettings();
            if (iextMaxZZPointsUsed > g_index_112 - 2) iextMaxZZPointsUsed = g_index_112 - 2;
            HAR_FoundPatterns_Reset();
            DropObjects("ZZ_POINT_");
            DropObjects("ZZ_LINE_");
            DropObjects("HAR_O_");
            if (bextDrawZZLine) HL_DrawZZline_ZigZag();
            if (bextDrawZZPoints) HL_DrawZZPoints(extTextColor);
            if (bextShowHistoryPatterns) {
               if (bextDrawZZRelations) {
                  HL_DrawZZrelline_ZigZag();
                  HL_DrawZZRelationsDesc(g_index_112 - 1, dextMaxDeviation, extTextColor);
               }
               if (bextCheckMultiZigzags) {
                  for (int li_0 = iextHL_MinSwing - dextHL_MultiZZMinSwingRange * iextHL_MinSwing; li_0 <= iextHL_MinSwing + dextHL_MultiZZMinSwingRange * iextHL_MinSwing; li_0 += iextHL_MinSwing / iextHL_MultiZZMinSwingNum) {
                     HL_Calculate(iextMaxBars, iextMaxZZPointsUsed, gi_192, li_0);
                     HAR_HarmonicPatternsAnalysis(g_index_112);
                  }
               } else HAR_HarmonicPatternsAnalysis(g_index_112);
            } else {
               if (bextDrawZZRelations) {
                  HL_DrawZZrelline_ZigZag();
                  HL_DrawZZRelationsDesc(iextMaxZZPointsUsed, dextMaxDeviation, extTextColor);
               }
               if (bextCheckMultiZigzags) {
                  for (li_0 = iextHL_MinSwing - dextHL_MultiZZMinSwingRange * iextHL_MinSwing; li_0 <= iextHL_MinSwing + dextHL_MultiZZMinSwingRange * iextHL_MinSwing; li_0 += iextHL_MinSwing / iextHL_MultiZZMinSwingNum) {
                     HL_Calculate(iextMaxBars, iextMaxZZPointsUsed, gi_192, li_0);
                     HAR_HarmonicPatternsAnalysis(iextMaxZZPointsUsed);
                  }
               } else HAR_HarmonicPatternsAnalysis(iextMaxZZPointsUsed);
            }
            if (HAR_FoundPatterns_IsChanged() == 1) {
               HAR_FoundPatterns_ShowPatterns();
               if (bextMT4AlertON && bextShowHistoryPatterns == FALSE) HAR_FoundPatterns_Alert(0);
               if (bextMT4EmailON && bextShowHistoryPatterns == FALSE) HAR_FoundPatterns_Alert(4);
               if (bextSoundAlertON) PlaySound(sextInfoPatternSoundFile);
               if (bextScreenshotPatternsON == TRUE && bextShowHistoryPatterns == FALSE) ScreenshotNewObjects();
               if (bextScreenshotPatternsON == TRUE && bextShowHistoryPatterns == FALSE) ScreenshotLostObjects();
               if (bextSigWebMonitonitoringON == TRUE && bextShowHistoryPatterns == FALSE) SigWebMonitoring();
               if (bextSigMonitonitoringON == TRUE) SIGMON_FoundPatterns_Save(sextSigMonitoringDir + "korHarmonicsSig" + "_" + Symbol() + "_" + PeriodDesc(Period()) + ".csv");
               HAR_FoundPatterns_StoreCurr();
            }
         }
      }
   }
}

void HAR_HarmonicPatternsAnalysis(int ai_0) {
   double l_str2dbl_4;
   double l_str2dbl_12;
   double l_str2dbl_20;
   double l_str2dbl_28;
   double l_str2dbl_36;
   double l_str2dbl_44;
   double l_str2dbl_52;
   double l_str2dbl_60;
   double l_str2dbl_68;
   int l_str2time_108;
   int l_str2time_112;
   int l_str2time_116;
   int l_str2time_120;
   int l_str2time_124;
   int l_str2time_128;
   int l_str2time_132;
   int l_str2time_136;
   int l_str2time_140;
   int li_160;
   int li_168;
   int li_172;
   bool li_176;
   double l_str2dbl_200;
   double l_str2dbl_208;
   if (bextFibo || bextFibo382 || bextFibo500 || bextFibo618 || bextFibo786 || bextFibo886) {
      if (bextShowHistoryPatterns == FALSE) li_172 = 5;
      else li_172 = ai_0;
      for (int li_164 = g_index_112 - li_172; li_164 <= g_index_112 - 3; li_164++) {
         l_str2time_112 = StrToTime(gsa_84[li_164][0]);
         l_str2dbl_12 = StrToDouble(gsa_84[li_164][1]);
         l_str2time_116 = StrToTime(gsa_84[li_164 + 1][0]);
         l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1][1]);
         l_str2time_120 = StrToTime(gsa_84[li_164 + 2][0]);
         l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 2][1]);
         if (bextFibo) {
            li_160 = Is_Pattern_Fibo(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, dextFiboDeviation);
            if (li_160 > 0) Draw_Pattern_Fibo(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28);
         }
         if (bextFibo382) {
            li_160 = Is_Pattern_FiboExact(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, 0.382, dextFiboDeviation);
            if (li_160 > 0) Draw_Pattern_Fibo(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28);
         }
         if (bextFibo500) {
            li_160 = Is_Pattern_FiboExact(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, 0.5, dextFiboDeviation);
            if (li_160 > 0) Draw_Pattern_Fibo(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28);
         }
         if (bextFibo618) {
            li_160 = Is_Pattern_FiboExact(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, 0.618, dextFiboDeviation);
            if (li_160 > 0) Draw_Pattern_Fibo(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28);
         }
         if (bextFibo786) {
            li_160 = Is_Pattern_FiboExact(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, 0.786, dextFiboDeviation);
            if (li_160 > 0) Draw_Pattern_Fibo(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28);
         }
         if (bextFibo886) {
            li_160 = Is_Pattern_FiboExact(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, 0.886, dextFiboDeviation);
            if (li_160 > 0) Draw_Pattern_Fibo(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28);
         }
      }
   }
   if (bextABCD || bextI_ABCD || bextIT_ABCD || bextBatman || bextWXY) {
      if (bextShowHistoryPatterns == FALSE) li_168 = 4;
      else li_168 = ai_0;
      for (li_164 = g_index_112 - li_168; li_164 <= g_index_112 - 4; li_164++) {
         l_str2time_112 = StrToTime(gsa_84[li_164][0]);
         l_str2dbl_12 = StrToDouble(gsa_84[li_164][1]);
         l_str2time_116 = StrToTime(gsa_84[li_164 + 1][0]);
         l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1][1]);
         l_str2time_120 = StrToTime(gsa_84[li_164 + 2][0]);
         l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 2][1]);
         l_str2time_124 = StrToTime(gsa_84[li_164 + 3][0]);
         l_str2dbl_36 = StrToDouble(gsa_84[li_164 + 3][1]);
         li_160 = Is_Pattern_ABCD(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, dextMaxDeviation);
         if (li_160 > 0) Draw_Pattern_ABCD(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36);
         li_160 = Is_Pattern_Batman(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36);
         if (li_160 > 0) Draw_Pattern_Batman(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36);
         li_160 = Is_Pattern_WXY(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, dextMaxDeviation);
         if (li_160 > 0) Draw_Pattern_WXY(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36);
      }
   }
   for (li_164 = g_index_112 - ai_0; li_164 <= g_index_112 - 5; li_164++) {
      l_str2time_112 = StrToTime(gsa_84[li_164][0]);
      l_str2dbl_12 = StrToDouble(gsa_84[li_164][1]);
      l_str2time_116 = StrToTime(gsa_84[li_164 + 1][0]);
      l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1][1]);
      l_str2time_120 = StrToTime(gsa_84[li_164 + 2][0]);
      l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 2][1]);
      l_str2time_124 = StrToTime(gsa_84[li_164 + 3][0]);
      l_str2dbl_36 = StrToDouble(gsa_84[li_164 + 3][1]);
      l_str2time_128 = StrToTime(gsa_84[li_164 + 4][0]);
      l_str2dbl_44 = StrToDouble(gsa_84[li_164 + 4][1]);
      if (li_164 != g_index_112 - 5) li_176 = FALSE;
      else {
         if (bextEmergingPatterns) li_176 = TRUE;
         else li_176 = FALSE;
      }
      li_160 = Is_MultiDimPattern(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, dextMaxDeviation, li_176);
      if (li_160 > 0) Draw_MultiDimPattern(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, dextMaxDeviation);
   }
   for (li_164 = g_index_112 - ai_0; li_164 <= g_index_112 - 7; li_164++) {
      l_str2time_136 = StrToTime(gsa_84[li_164][0]);
      l_str2dbl_60 = StrToDouble(gsa_84[li_164][1]);
      l_str2time_140 = StrToTime(gsa_84[li_164 + 1][0]);
      l_str2dbl_68 = StrToDouble(gsa_84[li_164 + 1][1]);
      for (int l_count_180 = 0; l_count_180 <= 1; l_count_180++) {
         if (li_164 + 1 + 1 + l_count_180 * 2 < g_index_112) {
            l_str2time_112 = StrToTime(gsa_84[li_164 + 1 + 1 + l_count_180 * 2][0]);
            l_str2dbl_12 = StrToDouble(gsa_84[li_164 + 1 + 1 + l_count_180 * 2][1]);
            if (l_count_180 == 1) {
               l_str2dbl_200 = StrToDouble(gsa_84[li_164 + 1 + 1][1]);
               l_str2dbl_208 = StrToDouble(gsa_84[li_164 + 1 + 2][1]);
               if ((l_str2dbl_68 < l_str2dbl_200 && l_str2dbl_68 < l_str2dbl_208 && l_str2dbl_12 > l_str2dbl_200 && l_str2dbl_12 > l_str2dbl_208 && l_str2dbl_200 > l_str2dbl_208) ||
                  (l_str2dbl_68 > l_str2dbl_200 && l_str2dbl_68 > l_str2dbl_208 && l_str2dbl_12 < l_str2dbl_200 && l_str2dbl_12 < l_str2dbl_208 && l_str2dbl_200 < l_str2dbl_208) == FALSE) continue;
            }
            for (int l_count_184 = 0; l_count_184 <= 1; l_count_184++) {
               if (li_164 + 1 + (l_count_180 * 2 + 1) + 1 + l_count_184 * 2 < g_index_112) {
                  l_str2time_116 = StrToTime(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + 1 + l_count_184 * 2][0]);
                  l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + 1 + l_count_184 * 2][1]);
                  if (l_count_184 == 1) {
                     l_str2dbl_200 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + 1][1]);
                     l_str2dbl_208 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + 2][1]);
                     if ((l_str2dbl_20 < l_str2dbl_200 && l_str2dbl_20 < l_str2dbl_208 && l_str2dbl_12 > l_str2dbl_200 && l_str2dbl_12 > l_str2dbl_208 && l_str2dbl_200 < l_str2dbl_208) ||
                        (l_str2dbl_20 > l_str2dbl_200 && l_str2dbl_20 > l_str2dbl_208 && l_str2dbl_12 < l_str2dbl_200 && l_str2dbl_12 < l_str2dbl_208 && l_str2dbl_200 > l_str2dbl_208) == FALSE) continue;
                  }
                  for (int l_count_188 = 0; l_count_188 <= 1; l_count_188++) {
                     if (li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) < g_index_112) {
                        l_str2time_120 = StrToTime(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1)][0]);
                        l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1)][1]);
                        if (l_count_188 == 1) {
                           l_str2dbl_200 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + 1][1]);
                           l_str2dbl_208 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + 2][1]);
                           if ((l_str2dbl_28 < l_str2dbl_200 && l_str2dbl_28 < l_str2dbl_208 && l_str2dbl_20 > l_str2dbl_200 && l_str2dbl_20 > l_str2dbl_208 && l_str2dbl_200 < l_str2dbl_208) ||
                              (l_str2dbl_28 > l_str2dbl_200 && l_str2dbl_28 > l_str2dbl_208 && l_str2dbl_20 < l_str2dbl_200 && l_str2dbl_20 < l_str2dbl_208 && l_str2dbl_200 > l_str2dbl_208) == FALSE) continue;
                        }
                        for (int l_count_192 = 0; l_count_192 <= 1; l_count_192++) {
                           if (li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1) < g_index_112) {
                              l_str2time_124 = StrToTime(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1)][0]);
                              l_str2dbl_36 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1)][1]);
                              if (l_count_192 == 1) {
                                 l_str2dbl_200 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + 1][1]);
                                 l_str2dbl_208 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + 2][1]);
                                 if ((l_str2dbl_36 < l_str2dbl_200 && l_str2dbl_36 < l_str2dbl_208 && l_str2dbl_28 > l_str2dbl_200 && l_str2dbl_28 > l_str2dbl_208 && l_str2dbl_200 < l_str2dbl_208) ||
                                    (l_str2dbl_36 > l_str2dbl_200 && l_str2dbl_36 > l_str2dbl_208 && l_str2dbl_28 < l_str2dbl_200 && l_str2dbl_28 < l_str2dbl_208 && l_str2dbl_200 > l_str2dbl_208) == FALSE) continue;
                              }
                              for (int l_count_196 = 0; l_count_196 <= 1; l_count_196++) {
                                 if (li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1) + (l_count_196 * 2 + 1) < g_index_112) {
                                    l_str2time_128 = StrToTime(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1) + (l_count_196 * 2 + 1)][0]);
                                    l_str2dbl_44 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1) + (l_count_196 * 2 + 1)][1]);
                                    if (l_count_196 == 1) {
                                       l_str2dbl_200 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1) + 1][1]);
                                       l_str2dbl_208 = StrToDouble(gsa_84[li_164 + 1 + (l_count_180 * 2 + 1) + (l_count_184 * 2 + 1) + (l_count_188 * 2 + 1) + (l_count_192 * 2 + 1) + 2][1]);
                                       if ((l_str2dbl_44 < l_str2dbl_200 && l_str2dbl_44 < l_str2dbl_208 && l_str2dbl_36 > l_str2dbl_200 && l_str2dbl_36 > l_str2dbl_208 && l_str2dbl_200 < l_str2dbl_208) ||
                                          (l_str2dbl_44 > l_str2dbl_200 && l_str2dbl_44 > l_str2dbl_208 && l_str2dbl_36 < l_str2dbl_200 && l_str2dbl_36 < l_str2dbl_208 && l_str2dbl_200 > l_str2dbl_208) == FALSE) continue;
                                    }
                                    li_160 = Is_TriangleC1(l_str2time_136, l_str2dbl_60, l_str2time_140, l_str2dbl_68, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, dextMaxTriangleDeviation);
                                    if (li_160 > 0) Draw_Triangle(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44);
                                    li_160 = Is_IConTriangle(l_str2time_136, l_str2dbl_60, l_str2time_140, l_str2dbl_68, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, dextMaxTriangleDeviation);
                                    if (li_160 > 0) Draw_Triangle(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44);
                                    li_160 = Is_NIConTriangle(l_str2time_136, l_str2dbl_60, l_str2time_140, l_str2dbl_68, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, dextMaxTriangleDeviation);
                                    if (li_160 > 0) Draw_Triangle(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44);
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
   for (li_164 = g_index_112 - ai_0; li_164 <= g_index_112 - 6; li_164++) {
      l_str2time_108 = StrToTime(gsa_84[li_164][0]);
      l_str2dbl_4 = StrToDouble(gsa_84[li_164][1]);
      l_str2time_112 = StrToTime(gsa_84[li_164 + 1][0]);
      l_str2dbl_12 = StrToDouble(gsa_84[li_164 + 1][1]);
      l_str2time_116 = StrToTime(gsa_84[li_164 + 2][0]);
      l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 2][1]);
      l_str2time_120 = StrToTime(gsa_84[li_164 + 3][0]);
      l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 3][1]);
      l_str2time_124 = StrToTime(gsa_84[li_164 + 4][0]);
      l_str2dbl_36 = StrToDouble(gsa_84[li_164 + 4][1]);
      l_str2time_128 = StrToTime(gsa_84[li_164 + 5][0]);
      l_str2dbl_44 = StrToDouble(gsa_84[li_164 + 5][1]);
      li_160 = Is_DiaTriangle(l_str2time_108, l_str2dbl_4, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, dextMaxTriangleDeviation);
      if (li_160 > 0) Draw_DiaTriangle(li_160, l_str2time_108, l_str2dbl_4, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44);
   }
   for (li_164 = g_index_112 - ai_0; li_164 <= g_index_112 - 6; li_164++) {
      l_str2time_112 = StrToTime(gsa_84[li_164][0]);
      l_str2dbl_12 = StrToDouble(gsa_84[li_164][1]);
      l_str2time_116 = StrToTime(gsa_84[li_164 + 1][0]);
      l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1][1]);
      l_str2time_120 = StrToTime(gsa_84[li_164 + 2][0]);
      l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 2][1]);
      l_str2time_124 = StrToTime(gsa_84[li_164 + 3][0]);
      l_str2dbl_36 = StrToDouble(gsa_84[li_164 + 3][1]);
      l_str2time_128 = StrToTime(gsa_84[li_164 + 4][0]);
      l_str2dbl_44 = StrToDouble(gsa_84[li_164 + 4][1]);
      l_str2time_132 = StrToTime(gsa_84[li_164 + 5][0]);
      l_str2dbl_52 = StrToDouble(gsa_84[li_164 + 5][1]);
      li_160 = Is_SHSPattern(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, l_str2time_132, l_str2dbl_52, dextMaxSHSPriceDeviation, dextMaxSHSTimeDeviation);
      if (li_160 > 0) Draw_Pattern_SHS(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, l_str2time_132, l_str2dbl_52);
      li_160 = Is_3DrivesPattern(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, l_str2time_132, l_str2dbl_52, dextMaxDeviation);
      if (li_160 > 0) Draw_Pattern_3Drives(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, l_str2time_132, l_str2dbl_52);
      li_160 = Is_5_0Pattern(l_str2dbl_12, l_str2dbl_20, l_str2dbl_28, l_str2dbl_36, l_str2dbl_44, l_str2dbl_52, dextMaxDeviation);
      if (li_160 > 0) Draw_Pattern_5_0(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44, l_str2time_132, l_str2dbl_52);
   }
   if (gi_528 || bextOne2One || bextEOne2One || bextSOne2One) {
      for (li_164 = g_index_112 - ai_0; li_164 <= g_index_112 - 5; li_164++) {
         l_str2time_112 = StrToTime(gsa_84[li_164][0]);
         l_str2dbl_12 = StrToDouble(gsa_84[li_164][1]);
         l_str2time_116 = StrToTime(gsa_84[li_164 + 1][0]);
         l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1][1]);
         l_str2time_120 = StrToTime(gsa_84[li_164 + 2][0]);
         l_str2dbl_28 = StrToDouble(gsa_84[li_164 + 2][1]);
         l_str2time_124 = StrToTime(gsa_84[li_164 + 3][0]);
         l_str2dbl_36 = StrToDouble(gsa_84[li_164 + 3][1]);
         l_str2time_128 = StrToTime(gsa_84[li_164 + 4][0]);
         l_str2dbl_44 = StrToDouble(gsa_84[li_164 + 4][1]);
         if (li_164 != g_index_112 - 5) li_176 = FALSE;
         else {
            if (bextEmergingPatterns) li_176 = TRUE;
            else li_176 = FALSE;
         }
         li_160 = Is_OmarPattern(l_str2dbl_12, l_str2dbl_20, l_str2dbl_28, l_str2dbl_36, l_str2dbl_44, dextMaxCorrDeviation);
         if (li_160 > 0) Draw_OmarPattern(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44);
         li_160 = Is_EOne2OnePattern(l_str2dbl_12, l_str2dbl_20, l_str2dbl_28, l_str2dbl_36, l_str2dbl_44, dextMaxOne2OneDeviation, li_176);
         if (li_160 > 0) Draw_EOne2OnePattern(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, l_str2time_120, l_str2dbl_28, l_str2time_124, l_str2dbl_36, l_str2time_128, l_str2dbl_44);
      }
   }
   if (gi_564) {
      for (li_164 = g_index_112 - ai_0; li_164 <= g_index_112 - 2; li_164++) {
         l_str2time_112 = StrToTime(gsa_84[li_164][0]);
         l_str2dbl_12 = StrToDouble(gsa_84[li_164][1]);
         l_str2time_116 = StrToTime(gsa_84[li_164 + 1][0]);
         l_str2dbl_20 = StrToDouble(gsa_84[li_164 + 1][1]);
         li_160 = Is_VibrationPattern(l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20, gd_576, gd_592);
         if (li_160 > 0) Draw_VibrationPattern(li_160, l_str2time_112, l_str2dbl_12, l_str2time_116, l_str2dbl_20);
      }
   }
}

int Is_Pattern_ABCD(int ai_0, double ad_4, int ai_12, double ad_16, int ai_24, double ad_28, int ai_36, double ad_40, double ad_48) {
   if (ad_4 - ad_16 == 0.0) return (0);
   double ld_56 = (ad_28 - ad_16) / (ad_4 - ad_16);
   int li_64 = iBarShift(Symbol(), Period(), ai_0) - iBarShift(Symbol(), Period(), ai_24);
   int li_68 = iBarShift(Symbol(), Period(), ai_12) - iBarShift(Symbol(), Period(), ai_36);
   if (bextIT_ABCD && MathAbs(ad_40 - ad_28) >= MathAbs(ad_16 - ad_4) * (1.0 - ad_48) && MathAbs(ad_40 - ad_28) <= MathAbs(ad_16 - ad_4) * (ad_48 + 1.0) && ld_56 >= 0.618 * (1 - ad_48) &&
      ld_56 <= 0.786 * (ad_48 + 1.0) && (li_64 >= li_68 * (1.0 - ad_48) && li_64 <= li_68 * (ad_48 + 1.0))) {
      if (ad_4 > ad_16) {
         HAR_FoundPatterns_Increase(5);
         SIGMON_FoundPatterns_Set(2, 1);
         return (5);
      }
      if (ad_4 < ad_16) {
         HAR_FoundPatterns_Increase(6);
         SIGMON_FoundPatterns_Set(2, -1);
         return (6);
      }
   } else {
      if (bextI_ABCD && MathAbs(ad_40 - ad_28) > MathAbs(ad_16 - ad_4) * (1.0 - ad_48) && MathAbs(ad_40 - ad_28) < MathAbs(ad_16 - ad_4) * (ad_48 + 1.0) && ld_56 >= 0.618 * (1 - ad_48) &&
         ld_56 <= 0.786 * (ad_48 + 1.0)) {
         if (ad_4 > ad_16) {
            HAR_FoundPatterns_Increase(3);
            SIGMON_FoundPatterns_Set(1, 1);
            return (3);
         }
         if (ad_4 >= ad_16) return (0);
         HAR_FoundPatterns_Increase(4);
         SIGMON_FoundPatterns_Set(1, -1);
         return (4);
      }
      if (bextABCD && MathAbs(ad_40 - ad_28) > MathAbs(ad_16 - ad_4) * (1.0 - ad_48) && MathAbs(ad_40 - ad_28) < MathAbs(ad_16 - ad_4) * (ad_48 + 1.0)) {
         if (ad_4 > ad_16) {
            HAR_FoundPatterns_Increase(1);
            SIGMON_FoundPatterns_Set(0, 1);
            return (1);
         }
         if (ad_4 >= ad_16) return (0);
         HAR_FoundPatterns_Increase(2);
         SIGMON_FoundPatterns_Set(0, -1);
         return (2);
      }
      return (0);
   }
   return (0);
}

int Is_Pattern_WXY(int ai_0, double ad_4, int ai_12, double ad_16, int ai_24, double ad_28, int ai_36, double ad_40, double ad_48) {
   if (ad_4 - ad_16 == 0.0 || ad_28 - ad_16 == 0.0) return (0);
   double ld_56 = (ad_28 - ad_16) / (ad_4 - ad_16);
   double ld_64 = (ad_28 - ad_40) / (ad_28 - ad_16);
   int li_72 = iBarShift(Symbol(), Period(), ai_0) - iBarShift(Symbol(), Period(), ai_24);
   int li_76 = iBarShift(Symbol(), Period(), ai_12) - iBarShift(Symbol(), Period(), ai_36);
   if (bextWXY && (ld_56 >= (1 - ad_48) / 2.0 && ld_56 <= (ad_48 + 1.0) / 2.0 && ld_64 >= 1.618 * (1 - ad_48) && ld_64 <= 1.618 * (ad_48 + 1.0)) || (ld_56 >= 0.618 * (1 - ad_48) &&
      ld_56 <= 0.618 * (ad_48 + 1.0) && ld_64 >= 1.618 * (1 - ad_48) && ld_64 <= 1.618 * (ad_48 + 1.0)) || (ld_56 >= (1 - ad_48) / 2.0 && ld_56 <= (ad_48 + 1.0) / 2.0 && ld_64 >= 2.618 * (1 - ad_48) && ld_64 <= 2.618 * (ad_48 +
      1.0)) || (ld_56 >= 0.618 * (1 - ad_48) && ld_56 <= 0.618 * (ad_48 + 1.0) && ld_64 >= 2.618 * (1 - ad_48) && ld_64 <= 2.618 * (ad_48 + 1.0)) && (li_76 >= 1.0 * li_72 * (1.0 - ad_48) &&
      li_76 <= 1.0 * li_72 * (ad_48 + 1.0) || li_76 >= 1.618 * li_72 * (1.0 - ad_48) && li_76 <= 1.618 * li_76 * (ad_48 + 1.0))) {
      if (ad_4 > ad_16) {
         HAR_FoundPatterns_Increase(64);
         SIGMON_FoundPatterns_Set(25, 1);
         return (64);
      }
      if (ad_4 < ad_16) {
         HAR_FoundPatterns_Increase(65);
         SIGMON_FoundPatterns_Set(25, -1);
         return (65);
      }
   } else return (0);
   return (0);
}

int Is_Pattern_Batman(int ai_unused_0, double ad_4, int ai_unused_12, double ad_16, int ai_unused_24, double ad_28, int ai_unused_36, double ad_40) {
   if (ad_4 - ad_16 == 0.0 || ad_28 - ad_16 == 0.0) return (0);
   double ld_48 = (ad_28 - ad_16) / (ad_4 - ad_16);
   double ld_56 = (ad_28 - ad_40) / (ad_28 - ad_16);
   if (bextBatman && ld_48 >= 1.0 && ld_48 <= 1.27 && ld_56 >= 0.73 && ld_56 <= 1.27) {
      if (ad_4 > ad_16 && ad_28 >= ad_4 && ad_28 > ad_16 && ad_40 < ad_4 && ad_40 < ad_28) {
         HAR_FoundPatterns_Increase(27);
         SIGMON_FoundPatterns_Set(26, 1);
         return (27);
      }
      if (!(ad_4 < ad_16 && ad_28 <= ad_4 && ad_28 < ad_16 && ad_40 > ad_4 && ad_40 > ad_28)) return (0);
      HAR_FoundPatterns_Increase(28);
      SIGMON_FoundPatterns_Set(26, -1);
      return (28);
   }
   return (0);
}

int Is_MultiDimPattern(int ai_0, double ad_4, int ai_12, double ad_16, int ai_24, double ad_28, int ai_36, double ad_40, int ai_48, double ad_52, double ad_60, int ai_68) {
   if (ad_16 - ad_4 == 0.0 || ad_40 - ad_28 == 0.0 || ad_16 - ad_28 == 0.0) return (0);
   double ld_72 = (ad_16 - ad_28) / (ad_16 - ad_4);
   double ld_80 = (ad_16 - ad_52) / (ad_16 - ad_4);
   double ld_88 = (ad_40 - ad_52) / (ad_40 - ad_28);
   double ld_96 = (ad_40 - ad_28) / (ad_16 - ad_28);
   double ld_104 = MathAbs(ad_28 - ad_16);
   double ld_112 = MathAbs(ad_52 - ad_40);
   double ld_120 = MathAbs(ad_4 - ad_16);
   int li_128 = iBarShift(Symbol(), Period(), ai_12) - iBarShift(Symbol(), Period(), ai_48);
   int li_132 = iBarShift(Symbol(), Period(), ai_24) - iBarShift(Symbol(), Period(), ai_48);
   int li_136 = iBarShift(Symbol(), Period(), ai_0) - iBarShift(Symbol(), Period(), ai_24);
   int li_140 = iBarShift(Symbol(), Period(), ai_0) - iBarShift(Symbol(), Period(), ai_12);
   int li_144 = iBarShift(Symbol(), Period(), ai_12) - iBarShift(Symbol(), Period(), ai_24);
   int li_148 = iBarShift(Symbol(), Period(), ai_24) - iBarShift(Symbol(), Period(), ai_36);
   int li_152 = iBarShift(Symbol(), Period(), ai_36) - iBarShift(Symbol(), Period(), ai_48);
   if ((bextGartley && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 0.786 * (1 - ad_60) && ld_80 <= 0.786 * (ad_60 + 1.0) && ld_88 >= 1.272 * (1 - ad_60) &&
      ld_88 <= 1.618 * (ad_60 + 1.0) && ld_72 >= 0.618 * (1 - ad_60) && ld_72 <= 0.618 * (ad_60 + 1.0) && (ld_104 >= ld_112 * (1 - ad_60) && ld_104 <= ld_112 * (ad_60 +
      1.0)) && (li_128 >= 0.618 * li_140 * (1 - ad_60) && li_128 <= 2.618 * li_140 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_152 > 1))) || (bextGartley && bextIdealGartleyOnly == FALSE &&
      ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 0.577 * (1 - ad_60) && ld_80 <= 0.786 * (ad_60 + 1.0) && ld_88 >= 1.272 * (1 - ad_60) && ld_88 <= 2.2236 * (ad_60 +
      1.0) && ld_72 >= (1 - ad_60) / 2.0 && ld_72 <= 0.618 * (ad_60 + 1.0) && (li_144 >= li_152 / 2.0 * (1 - ad_60) && li_144 <= 1.618 * li_152 * (ad_60 + 1.0)) || (li_152 >= li_144 / 2.0 * (1 - ad_60) && li_152 <= 1.618 * li_144 * (ad_60 +
      1.0)) && (li_128 >= 0.618 * li_140 * (1 - ad_60) && li_128 <= 2.618 * li_140 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_152 > 1)))) {
      if (ad_16 > ad_40 && ad_40 > ad_28 && ad_28 > ad_4 && ad_52 > ad_4) {
         HAR_FoundPatterns_Increase(7);
         SIGMON_FoundPatterns_Set(3, 1);
         return (7);
      }
      if (ad_16 < ad_40 && ad_40 < ad_28 && ad_28 < ad_4 && ad_52 < ad_4) {
         HAR_FoundPatterns_Increase(8);
         SIGMON_FoundPatterns_Set(3, -1);
         return (8);
      }
   }
   if ((bextButterfly && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 1.27 * (1 - ad_60) && ld_80 <= 1.618 * (ad_60 + 1.0) && ld_88 >= 1.618 * (1 - ad_60) &&
      ld_88 <= 2.618 * (ad_60 + 1.0) && ld_72 >= 0.786 * (1 - ad_60) && ld_72 <= 0.786 * (ad_60 + 1.0) && (ld_112 >= 1.0 * ld_104 * (1 - ad_60) && ld_112 <= 1.0 * ld_104 * (ad_60 +
      1.0)) && (li_132 >= 0.618 * li_136 * (1 - ad_60) && li_132 <= 2.618 * li_136 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 && li_152 > 1))) || (bextButterfly &&
      bextIdealButterflyOnly == FALSE && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 1.27 * (1 - ad_60) && ld_80 <= 1.618 * (ad_60 + 1.0) && ld_88 >= 1.618 * (1 - ad_60) && ld_88 <= 2.618 * (ad_60 +
      1.0) && ld_72 >= 0.618 * (1 - ad_60) && ld_72 <= 0.786 * (ad_60 + 1.0) && (ld_112 >= 1.0 * ld_104 * (1 - ad_60) && ld_112 <= 1.618 * ld_104 * (ad_60 + 1.0)))) {
      if (ad_16 > ad_40 && ad_40 > ad_28 && ad_28 > ad_4 && ad_52 < ad_4) {
         HAR_FoundPatterns_Increase(9);
         SIGMON_FoundPatterns_Set(4, 1);
         return (9);
      }
      if (ad_16 < ad_40 && ad_40 < ad_28 && ad_28 < ad_4 && ad_52 > ad_4) {
         HAR_FoundPatterns_Increase(10);
         SIGMON_FoundPatterns_Set(4, -1);
         return (10);
      }
   } else {
      if ((bextCrab && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 1.272 * (1 - ad_60) && ld_80 <= 1.618 * (ad_60 + 1.0) && ld_88 >= 2.24 * (1 - ad_60) &&
         ld_88 <= 3.618 * (ad_60 + 1.0) && ld_72 >= (1 - ad_60) / 2.0 && ld_72 <= 0.618 * (ad_60 + 1.0) && (li_132 >= 0.618 * li_136 * (1 - ad_60) && li_132 <= 2.618 * li_136 * (ad_60 +
         1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 && li_152 > 1))) || (bextCrab && bextIdealCrabOnly == FALSE && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 +
         1.0) && ld_80 >= 1.272 * (1 - ad_60) && ld_80 <= 1.618 * (ad_60 + 1.0) && ld_88 >= 2.24 * (1 - ad_60) && ld_88 <= 3.618 * (ad_60 + 1.0) && ld_72 >= (1 - ad_60) / 2.0 &&
         ld_72 <= 0.886 * (ad_60 + 1.0) && (li_132 >= 0.618 * li_136 * (1 - ad_60) && li_132 <= 1.618 * li_136 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 &&
         li_152 > 1)))) {
         if (ad_16 > ad_40 && ad_40 > ad_28 && ad_28 > ad_4 && ad_52 < ad_4) {
            HAR_FoundPatterns_Increase(11);
            SIGMON_FoundPatterns_Set(5, 1);
            return (11);
         }
         if (ad_16 < ad_40 && ad_40 < ad_28 && ad_28 < ad_4 && ad_52 > ad_4) {
            HAR_FoundPatterns_Increase(12);
            SIGMON_FoundPatterns_Set(5, -1);
            return (12);
         }
      }
      if ((bextBat && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 0.886 * (1 - ad_60) && ld_80 <= 0.886 * (ad_60 + 1.0) && ld_88 >= 1.618 * (1 - ad_60) &&
         ld_88 <= 2.618 * (ad_60 + 1.0) && ld_72 >= (1 - ad_60) / 2.0 && ld_72 <= (ad_60 + 1.0) / 2.0 && (ld_112 >= 1.27 * ld_104 * (1 - ad_60) && ld_112 <= 1.618 * ld_104 * (ad_60 +
         1.0)) && (li_128 >= 0.618 * li_140 * (1 - ad_60) && li_128 <= 2.618 * li_140 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 && li_152 > 1))) || (bextBat &&
         bextIdealBatOnly == FALSE && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_80 >= 0.886 * (1 - ad_60) && ld_80 <= 0.886 * (ad_60 + 1.0) && ld_88 >= 1.618 * (1 - ad_60) && ld_88 <= 2.618 * (ad_60 +
         1.0) && ld_72 >= (1 - ad_60) / 2.0 && ld_72 <= 0.577 * (ad_60 + 1.0) && (li_128 >= 0.618 * li_140 * (1 - ad_60) && li_128 <= 2.618 * li_140 * (ad_60 + 1.0) && (li_140 > 1 &&
         li_144 > 1 && li_148 > 1 && li_152 > 1)))) {
         if (ad_16 > ad_40 && ad_40 > ad_28 && ad_28 > ad_4 && ad_52 > ad_4) {
            HAR_FoundPatterns_Increase(13);
            SIGMON_FoundPatterns_Set(6, 1);
            return (13);
         }
         if (ad_16 < ad_40 && ad_40 < ad_28 && ad_28 < ad_4 && ad_52 < ad_4) {
            HAR_FoundPatterns_Increase(14);
            SIGMON_FoundPatterns_Set(6, -1);
            return (14);
         }
      }
   }
   if ((bextIdealGartleyOnly && ai_68 && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_72 >= 0.618 * (1 - ad_60) && ld_72 <= 0.618 * (ad_60 + 1.0) &&
      ld_88 >= 1.27 * dextEmergingPatternPerc * (1 - ad_60) && ld_88 <= 1.618 * (ad_60 + 1.0) && (ld_80 >= 0.786 * dextEmergingPatternPerc * (1 - ad_60) && ld_80 < 0.786 * (ad_60 +
      1.0)) && (ld_112 >= dextEmergingPatternPerc * ld_104 * (1 - ad_60) && ld_112 <= ld_104 * (ad_60 + 1.0)) && (li_128 >= 0.618 * (dextEmergingPatternPerc * li_140) * (1 - ad_60) &&
      li_128 <= 2.618 * li_140 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 && li_152 > 1)) && MathAbs(ad_40 - High[0]) >= dextEmergingPatternPerc * ld_104 * (1 - ad_60) &&
      MathAbs(ad_40 - High[0]) <= ld_104 * (ad_60 + 1.0)) || (bextGartley && ai_68 && bextIdealGartleyOnly == FALSE && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 +
      1.0) && ld_72 >= (1 - ad_60) / 2.0 && ld_72 <= 0.618 * (ad_60 + 1.0) && ld_88 >= 1.27 * dextEmergingPatternPerc * (1 - ad_60) && ld_88 <= 2.2236 * (ad_60 + 1.0) &&
      (ld_80 >= 0.577 * dextEmergingPatternPerc * (1 - ad_60) && ld_80 < 0.786 * (ad_60 + 1.0)) && (li_128 >= 0.618 * (dextEmergingPatternPerc * li_140) * (1 - ad_60) &&
      li_128 <= 2.618 * li_140 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 && li_152 > 1)) && MathAbs(ad_40 - High[0]) >= dextEmergingPatternPerc * ld_104 * (1 - ad_60) &&
      MathAbs(ad_40 - High[0]) <= ld_104 * (ad_60 + 1.0))) {
      if (ad_16 > ad_40 && ad_40 > ad_28 && ad_28 > ad_4 && ad_52 > ad_4 && ad_52 <= ad_28) {
         HAR_FoundPatterns_Increase(15);
         SIGMON_FoundPatterns_Set(3, 2);
         return (15);
      }
      if (ad_16 < ad_40 && ad_40 < ad_28 && ad_28 < ad_4 && ad_52 < ad_4 && ad_52 >= ad_28) {
         HAR_FoundPatterns_Increase(16);
         SIGMON_FoundPatterns_Set(3, -2);
         return (16);
      }
   }
   if ((bextIdealButterflyOnly && ai_68 && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 + 1.0) && ld_72 >= 0.786 * (1 - ad_60) && ld_72 <= 0.786 * (ad_60 + 1.0) &&
      ld_88 >= 1.618 * dextEmergingPatternPerc * (1 - ad_60) && ld_88 <= 2.618 * (ad_60 + 1.0) && (ld_80 >= 1.27 * dextEmergingPatternPerc * (1 - ad_60) && ld_80 < 1.618 * (ad_60 +
      1.0)) && (ld_112 >= 1.0 * (dextEmergingPatternPerc * ld_104) * (1 - ad_60) && ld_112 <= 1.0 * ld_104 * (ad_60 + 1.0)) && (li_132 >= 0.618 * (dextEmergingPatternPerc * li_136) * (1 - ad_60) &&
      li_132 <= 2.618 * li_136 * (ad_60 + 1.0) && (li_140 > 1 && li_144 > 1 && li_148 > 1 && li_152 > 1)) && MathAbs(ad_40 - High[0]) >= 1.0 * (dextEmergingPatternPerc * ld_104) * (1 - ad_60) &&
      MathAbs(ad_40 - High[0]) <= 1.0 * ld_104 * (ad_60 + 1.0)) || (bextButterfly && ai_68 && bextIdealGartleyOnly == FALSE && ld_96 >= (1 - ad_60) / 2.0 && ld_96 <= 0.886 * (ad_60 +
      1.0) && ld_72 >= 0.618 * (1 - ad_60) && ld_72 <= 0.786 * (ad_60 + 1.0) && ld_88 >= 1.618 * dextEmergingPatternPerc         

Recommend