Navigation:Home > Content >

Fiba+v7Rus.mq4

Time: 2012-06-23 | Download file:Fiba+v7Rus.mq4

#property copyright "Copyright © 2005, Morin & Lhasa"
#property link      "http://www.fibaplus.com"

#property indicator_chart_window

double gd_76 = 0.764;
int gi_unused_84 = 255;
extern string Serial = "";
extern string Symbols = "";
extern color TargetColor = Red;
double gd_unused_108 = 42495.0;
extern color Level1 = Crimson;
extern color Level2 = Brown;
extern color Level3 = Chocolate;
extern color Level4 = Blue;
extern color Level5 = Gray;
extern color Level6 = Silver;
extern color Level7 = Honeydew;
extern color ShadowColor = Silver;
extern color CorercColor = Silver;
int gi_152 = 30;
double gd_156 = 0.02;
int gi_164 = 7;
int gi_168;
int gi_172;
string gs_176;
double gda_184[30][8];
double gda_188[5][6];
double gda_192[30][7];
int gia_196[] = {15133183, 13822719, 13303551, 14024672, 16777166};
string gsa_200[] = {"Stream", "Guard", "Rest", "Oblivion", "Meditation"};
int gia_204[] = {43200, 10080, 1440, 240, 60, 30, 15, 5, 1};
int gia_208[] = {3937500, 2763429, 1993170, 16711680, 8421504, 12632256, 15794160};
int gia_212[] = {4, 3, 2, 1, 1, 1, 1};
double gda_216[] = {0.381966011, 0.5, 0.618033989, 0.763932023, 0.854101966};
int gia_220[] = {0, 0, 0, 0, 0, 0, 0, 0};
string g_symbol_224;
int g_timeframe_232;

int init() {
   InitGlobalVariables();
   return (0);
}

int deinit() {
   Comment("");
   DeleteFans(0);
   DeleteClouds(0);
   DeleteCorLine(0);
   return (0);
}

int start() {
   int l_lowest_0;
   int l_highest_4;
   double ld_8;
   double ld_16;
   int l_highest_24;
   int l_lowest_28;
   int li_32;
   int li_36;
   double ld_unused_40;
   double ld_48;
   int l_timeframe_56;
   int li_60;
   double l_ifractals_64;
   int li_72;
   int li_76;
   int l_timeframe_80;
   int l_lowest_84;
   int l_highest_88;
   int l_lowest_92;
   double ld_96;
   double ld_104;
   double ld_112;
   gs_176 = "";
   InitGlobalVariables();
   int li_120 = 0;
   int l_index_124 = 0;
   bool li_128 = TRUE;
   int li_132 = 1;
   int li_136 = 0;
   int li_140 = gia_220[li_120];
   while (li_128) {
      l_highest_24 = iHighest(g_symbol_224, gia_204[li_120], MODE_HIGH, li_140 + 1 - gi_168, gi_168);
      l_lowest_28 = iLowest(g_symbol_224, gia_204[li_120], MODE_LOW, li_140 + 1 - gi_168, gi_168);
      if (l_lowest_28 > l_highest_24) {
         li_136 = 1;
         l_lowest_0 = l_lowest_28;
         l_highest_4 = l_highest_24;
         ld_8 = iLow(g_symbol_224, gia_204[li_120], l_lowest_0);
         ld_16 = iHigh(g_symbol_224, gia_204[li_120], l_highest_4);
      } else {
         li_136 = -1;
         l_lowest_0 = l_highest_24;
         l_highest_4 = l_lowest_28;
         ld_8 = iHigh(g_symbol_224, gia_204[li_120], l_lowest_0);
         ld_16 = iLow(g_symbol_224, gia_204[li_120], l_highest_4);
      }
      if (l_index_124 > 0)
         if (!TestPriority(gda_184[l_index_124 - 1][1], gda_184[l_index_124 - 1][2], gda_184[l_index_124 - 1][3], gda_184[l_index_124 - 1][4], BarConvert(gia_204[li_120], gda_184[l_index_124 - 1][5], l_highest_4, -li_136), ld_16, gd_76)) li_132++;
      gda_184[l_index_124][0] = li_132;
      gda_184[l_index_124][1] = l_lowest_0;
      gda_184[l_index_124][2] = ld_8;
      gda_184[l_index_124][3] = l_highest_4;
      gda_184[l_index_124][4] = ld_16;
      gda_184[l_index_124][5] = gia_204[li_120];
      gda_184[l_index_124][6] = li_136;
      DrawFibo("Веер " + ((l_index_124 + 1)), gia_204[li_120], gda_184[l_index_124][1], gda_184[l_index_124][2], gda_184[l_index_124][3], gda_184[l_index_124][4], gia_208[li_132 - 1], 255, li_132, gia_212[li_132 - 1]);
      if (BarConvert(gia_204[li_120], g_timeframe_232, l_highest_4, li_136) < gi_168 + 20) li_128 = FALSE;
      if (li_128 == FALSE) break;
      li_140 = l_highest_4;
      l_index_124++;
      for (int li_144 = PeriodToTF(g_timeframe_232); li_144 > li_120; li_144--) {
         if (li_140 != BarConvert(gia_204[li_120], gia_204[li_144], li_140, li_136) && BarConvert(gia_204[li_120], gia_204[li_144], li_140, li_136) < 5000 && gia_204[li_120] >= g_timeframe_232) {
            gs_176 = gs_176 + li_140 + " " + PeriodToString(gia_204[li_120]) + " -> ";
            li_140 = BarConvert(gia_204[li_120], gia_204[li_144], li_140, li_136);
            gs_176 = gs_176 + li_140 + " " + PeriodToString(gia_204[li_144]) 
            + "\n";
            li_120 = li_144;
            break;
         }
      }
   }
   ArrayResize(gda_184, l_index_124 + 1);
   DeleteFans(ArrayRange(gda_184, 0));
   int l_index_148 = 0;
   int li_152 = ArrayRange(gda_184, 0);
   double ld_156 = iClose(g_symbol_224, 0, 0);
   double ld_164 = -iClose(g_symbol_224, 0, 0);
   DeleteCorLine(0);
   for (int li_172 = li_152 - 1; li_172 > li_152 - 3; li_172--) {
      li_32 = gda_184[li_172][1];
      li_36 = gda_184[li_172][3];
      ld_unused_40 = gda_184[li_172][2];
      ld_48 = gda_184[li_172][4];
      l_timeframe_56 = gda_184[li_172][5];
      if (gda_184[li_172][6] > 0.0) li_60 = 2;
      else li_60 = 1;
      for (li_144 = li_36; li_144 < li_32; li_144++) {
         l_ifractals_64 = iFractals(g_symbol_224, l_timeframe_56, li_60, li_144);
         if (l_ifractals_64 > 0.0 && MathAbs(li_144 - li_36) > 2.0 && li_144 != 0) {
            if (CrossChart(g_symbol_224, l_timeframe_56, li_144, l_ifractals_64, li_36, ld_48) == 0) {
               gda_192[l_index_148][0] = 1;
               gda_192[l_index_148][1] = li_144;
               gda_192[l_index_148][2] = l_ifractals_64;
               gda_192[l_index_148][3] = li_36;
               gda_192[l_index_148][4] = ld_48;
               gda_192[l_index_148][5] = l_timeframe_56;
               if (gda_192[l_index_148][6] > 0.0 && ld_156 > gda_192[l_index_148][6]) {
                  li_72 = l_index_148;
                  ld_156 = gda_192[l_index_148][6];
               }
               if (gda_192[l_index_148][6] < 0.0 && ld_164 < gda_192[l_index_148][6]) {
                  li_76 = l_index_148;
                  ld_164 = gda_192[l_index_148][6];
               }
               l_index_148++;
            }
         }
      }
   }
   DrawCorLine("Коррекция " + ((li_72 + 1)), gda_192[li_72][5], gda_192[li_72][1], gda_192[li_72][2], gda_192[li_72][3], gda_192[li_72][4], DoubleToStr(MathAbs(gda_192[li_72][6]) / MarketInfo(g_symbol_224, MODE_TICKSIZE), 0) +
      " пипс.\n", CorercColor, 2);
   DrawCorLine("Коррекция " + ((li_76 + 1)), gda_192[li_76][5], gda_192[li_76][1], gda_192[li_76][2], gda_192[li_76][3], gda_192[li_76][4], DoubleToStr(MathAbs(gda_192[li_76][6]) / MarketInfo(g_symbol_224, MODE_TICKSIZE), 0) +
      " пипс.\n", CorercColor, 2);
   int li_176 = 0;
   for (l_index_124 = ArrayRange(gda_184, 0) - 1 - 3; l_index_124 <= ArrayRange(gda_184, 0) - 1; l_index_124++) {
      l_lowest_0 = gda_184[l_index_124][1];
      ld_8 = gda_184[l_index_124][2];
      l_highest_4 = gda_184[l_index_124][3];
      ld_16 = gda_184[l_index_124][4];
      l_timeframe_80 = gda_184[l_index_124][5];
      li_136 = gda_184[l_index_124][6];
      l_lowest_84 = l_lowest_0;
      for (li_144 = l_lowest_0; li_144 >= l_highest_4; li_144--) {
         if (li_136 > 0) {
            ld_96 = iLow(g_symbol_224, l_timeframe_80, l_lowest_84);
            l_highest_88 = iHighest(g_symbol_224, l_timeframe_80, MODE_HIGH, l_lowest_84 - li_144 + 1, li_144);
            ld_104 = iHigh(g_symbol_224, l_timeframe_80, l_highest_88);
            l_lowest_92 = iLowest(g_symbol_224, l_timeframe_80, MODE_LOW, l_highest_88 - li_144 + 1, li_144);
            ld_112 = iLow(g_symbol_224, l_timeframe_80, l_lowest_92);
         } else {
            ld_96 = iHigh(g_symbol_224, l_timeframe_80, l_lowest_84);
            l_highest_88 = iLowest(g_symbol_224, l_timeframe_80, MODE_LOW, l_lowest_84 - li_144 + 1, li_144);
            ld_104 = iLow(g_symbol_224, l_timeframe_80, l_highest_88);
            l_lowest_92 = iHighest(g_symbol_224, l_timeframe_80, MODE_HIGH, l_highest_88 - li_144 + 1, li_144);
            ld_112 = iHigh(g_symbol_224, l_timeframe_80, l_lowest_92);
         }
         if ((TestPriority(l_lowest_84, ld_96, l_highest_88, ld_104, l_lowest_92, ld_112, 0.5) && (l_lowest_84 - l_lowest_92 > gi_152 && MathAbs(ld_96 - ld_104) > gd_156)) ||
            li_144 == l_highest_4) {
            gda_188[li_176][0] = li_136;
            gda_188[li_176][1] = l_lowest_84;
            gda_188[li_176][2] = ld_96;
            gda_188[li_176][3] = l_highest_88;
            gda_188[li_176][4] = ld_104;
            gda_188[li_176][5] = l_timeframe_80;
            if (li_176 > 0 && (l_lowest_84 != FindExtr(g_symbol_224, l_timeframe_80, -li_136, l_lowest_84 - l_lowest_92 + 1, l_lowest_92) && l_lowest_92 != FindExtr(g_symbol_224, l_timeframe_80, -li_136, l_lowest_84 - l_lowest_92 +
               1, l_lowest_92))) {
               gda_188[li_176 - 1][3] = FindExtr(g_symbol_224, l_timeframe_80, -li_136, l_lowest_84 - l_lowest_92 + 1, l_lowest_92);
               gda_188[li_176 - 1][4] = Extr(g_symbol_224, l_timeframe_80, -li_136, gda_188[li_176 - 1][3]);
               gda_188[li_176][1] = gda_188[li_176 - 1][3];
               gda_188[li_176][2] = gda_188[li_176 - 1][4];
            }
            l_lowest_84 = l_highest_88;
            li_144 = l_lowest_84;
            li_136 = -li_136;
            li_176++;
            ArrayResize(gda_188, li_176 + 1);
         }
      }
   }
   gda_188[li_176][0] = li_136;
   gda_188[li_176][1] = gda_188[li_176 - 1][3];
   gda_188[li_176][2] = gda_188[li_176 - 1][4];
   gda_188[li_176][3] = gda_188[li_176 - 1][3] - 1.0;
   gda_188[li_176][4] = gda_188[li_176 - 1][4];
   gda_188[li_176][5] = l_timeframe_80;
   li_176++;
   ArrayResize(gda_188, li_176);
   for (li_144 = 0; li_144 < ArrayRange(gda_188, 0) - 1; li_144++) {
      DrawCloud("Cloud " + li_144, gda_188[li_144][5], gda_188[li_144][1], gda_188[li_144][2], gda_188[li_144][3], gda_188[li_144][4], BarConvert(gda_188[li_144 + 1][5], gda_188[li_144][5], gda_188[li_144 +
         1][3], gda_188[li_144 + 1][0]), gda_188[li_144 + 1][4], ArrayRange(gda_188, 0) - 1 - li_144 < 5, ShadowColor, 1);
   }
   DeleteClouds(ArrayRange(gda_188, 0));
   return (0);
}

int CrossChart(string a_symbol_0, int a_timeframe_8, int ai_12, double ad_16, int ai_24, double ad_28) {
   int li_36;
   double ld_40;
   if (ai_12 < ai_24) {
      li_36 = ai_12;
      ai_12 = ai_24;
      ai_24 = li_36;
   }
   if (ai_12 - ai_24 == 0) return (1);
   double ld_48 = (ad_28 - ad_16) / (ai_12 - ai_24);
   bool li_56 = FALSE;
   bool li_60 = FALSE;
   for (int li_64 = ai_12; li_64 > ai_24; li_64--) {
      ld_40 = ad_16 + ld_48 * li_36;
      if (iHigh(a_symbol_0, a_timeframe_8, li_64) > ld_40) li_56 = TRUE;
      if (iLow(a_symbol_0, a_timeframe_8, li_64) < ld_40) li_60 = TRUE;
      if (li_56 && li_60) return (1);
   }
   return (0);
}

double AverageBar(string a_symbol_0, int a_timeframe_8, int ai_12, int ai_16) {
   double ld_20;
   int li_28;
   for (int li_32 = ai_12; li_32 <= ai_16; li_32++) {
      ld_20 += MathAbs(iOpen(a_symbol_0, a_timeframe_8, li_32) - iClose(a_symbol_0, a_timeframe_8, li_32));
      li_28++;
   }
   if (li_28 == 0) return (0);
   return (ld_20 / li_28);
}

int DrawCloud(string a_name_0, int a_timeframe_8, double ad_12, double ad_20, double ad_28, double ad_36, int ai_44, double ad_48, bool ai_56, color a_color_60, int a_width_64) {
   double ld_68;
   double ld_76;
   double ld_84;
   int li_92;
   int li_96;
   double ld_100;
   string l_name_108;
   double ld_116;
   double ld_124;
   if (ad_28 - ai_44 == 0.0 || ad_12 - ad_28 == 0.0) return (0);
   int li_132 = ArrayRange(gda_216, 0);
   int li_136 = ad_28;
   double ld_140 = ad_36;
   for (int li_148 = 0; li_148 < li_132; li_148++) {
      ld_68 = (ad_48 - ad_36) / (ad_28 - ai_44);
      ld_76 = (ad_36 - ad_20) / (ad_12 - ad_28);
      ld_84 = 1 - gda_216[li_148];
      l_name_108 = a_name_0 + " " + gsa_200[li_148];
      if (ld_76 * ld_84 - ld_68 == 0.0) return (0);
      li_96 = MathCeil((ad_20 - ad_36 + ad_12 * ld_76 * ld_84 - ad_28 * ld_68) / (ld_76 * ld_84 - ld_68) - 0.5);
      li_92 = MathCeil(li_96);
      ld_116 = ad_20 + (ad_12 - li_92) * ld_76 * ld_84;
      ld_124 = ad_36 + (ad_28 - li_92) * ld_68;
      ld_100 = (ld_116 + ld_124) / 2.0;
      if (ObjectFind(l_name_108) != -1) {
         ObjectMove(l_name_108, 0, TimeBar(Symbol(), a_timeframe_8, ad_12), ad_20);
         ObjectMove(l_name_108, 1, TimeBar(Symbol(), a_timeframe_8, li_136), ld_140);
         ObjectMove(l_name_108, 2, TimeBar(Symbol(), a_timeframe_8, li_92), ld_100);
         ObjectSet(l_name_108, OBJPROP_COLOR, gia_196[li_148]);
         ObjectSet(l_name_108, OBJPROP_BACK, TRUE);
      } else {
         ObjectCreate(l_name_108, OBJ_TRIANGLE, 0, TimeBar(Symbol(), a_timeframe_8, ad_12), ad_20, TimeBar(Symbol(), a_timeframe_8, li_136), ld_140, TimeBar(Symbol(), a_timeframe_8, li_92), ld_100);
         ObjectSet(l_name_108, OBJPROP_COLOR, gia_196[li_148]);
         ObjectSet(l_name_108, OBJPROP_BACK, TRUE);
      }
      li_136 = li_92;
      ld_140 = ld_100;
   }
   if (ai_56) {
      if (ObjectFind(a_name_0) != -1) {
         ObjectMove(a_name_0, 0, iTime(Symbol(), a_timeframe_8, ad_12), ad_20);
         ObjectMove(a_name_0, 1, iTime(Symbol(), a_timeframe_8, ad_28), ad_36);
         ObjectSet(a_name_0, OBJPROP_COLOR, a_color_60);
         ObjectSet(a_name_0, OBJPROP_LEVELCOLOR, a_color_60);
         ObjectSet(a_name_0, OBJPROP_LEVELWIDTH, a_width_64);
         ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
      } else {
         ObjectCreate(a_name_0, OBJ_FIBOFAN, 0, iTime(Symbol(), a_timeframe_8, ad_12), ad_20, iTime(Symbol(), a_timeframe_8, ad_28), ad_36);
         ObjectSet(a_name_0, OBJPROP_COLOR, a_color_60);
         ObjectSet(a_name_0, OBJPROP_LEVELCOLOR, a_color_60);
         ObjectSet(a_name_0, OBJPROP_LEVELWIDTH, a_width_64);
         ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
         ObjectSet(a_name_0, OBJPROP_FIBOLEVELS, ArrayRange(gda_216, 0));
         for (li_148 = 0; li_148 < ArrayRange(gda_216, 0); li_148++) {
            ObjectSet(a_name_0, li_148 + 210, gda_216[li_148]);
            ObjectSetFiboDescription(a_name_0, li_148, "");
         }
      }
   } else ObjectDelete(a_name_0);
   return (0);
}

int TimeBar(string a_symbol_0, int a_timeframe_8, int ai_12) {
   if (ai_12 >= 0) return (iTime(a_symbol_0, a_timeframe_8, ai_12));
   int li_ret_16 = iTime(a_symbol_0, a_timeframe_8, 0) + 60 * a_timeframe_8 * MathAbs(ai_12);
   return (li_ret_16);
}

int FindExtr(string a_symbol_0, int a_timeframe_8, int ai_12, int ai_16, int ai_20) {
   if (ai_12 < 0) return (iLowest(a_symbol_0, a_timeframe_8, MODE_LOW, ai_16, ai_20));
   if (ai_12 > 0) return (iHighest(a_symbol_0, a_timeframe_8, MODE_HIGH, ai_16, ai_20));
   return (MathCeil(ai_20 + ai_16 / 2));
}

double Extr(string a_symbol_0, int a_timeframe_8, int ai_12, int ai_16) {
   if (ai_12 < 0) return (iLow(a_symbol_0, a_timeframe_8, ai_16));
   if (ai_12 > 0) return (iHigh(a_symbol_0, a_timeframe_8, ai_16));
   return ((iLow(a_symbol_0, a_timeframe_8, ai_16) + iHigh(a_symbol_0, a_timeframe_8, ai_16)) / 2.0);
}

int DrawCorLine(string a_name_0, int ai_8, int ai_12, double a_price_16, int ai_24, double a_price_28, string a_text_36, color a_color_44, int a_width_48) {
   int l_datetime_52;
   int l_datetime_56;
   if (a_price_16 < a_price_28) {
      l_datetime_52 = CTF(ai_8, ai_12, 1);
      l_datetime_56 = CTF(ai_8, ai_24, 2);
   } else {
      l_datetime_52 = CTF(ai_8, ai_12, 2);
      l_datetime_56 = CTF(ai_8, ai_24, 1);
   }
   a_price_28 = a_price_16 - 0.146 * (a_price_16 - a_price_28);
   if (ObjectFind(a_name_0) == -1) ObjectCreate(a_name_0, OBJ_TREND, 0, l_datetime_52, a_price_16, l_datetime_56, a_price_28);
   ObjectMove(a_name_0, 0, l_datetime_52, a_price_16);
   ObjectMove(a_name_0, 1, l_datetime_56, a_price_28);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_44);
   ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
   ObjectSet(a_name_0, OBJPROP_FIRSTLEVEL, 0.854);
   ObjectSet(a_name_0, OBJPROP_WIDTH, a_width_48);
   ObjectSetText(a_name_0, a_text_36, 10, "Times New Roman", Green);
   return (0);
}

int DrawFibo(string as_0, int ai_8, int ai_12, double ad_16, int ai_24, double ad_28, int ai_36, int ai_40, int ai_44, int ai_48) {
   int li_52;
   int li_56;
   int li_60;
   string ls_64;
   if (ad_16 < ad_28) {
      li_52 = CTF(ai_8, ai_12, 1);
      li_56 = CTF(ai_8, ai_24, 2);
   } else {
      li_52 = CTF(ai_8, ai_12, 2);
      li_56 = CTF(ai_8, ai_24, 1);
   }
   for (int l_index_72 = 0; l_index_72 <= ArrayRange(gda_216, 0) - 1; l_index_72++) {
      li_60 = ai_36;
      ls_64 = "Приоритет " + ai_44 
      + "\nУров. " + DoubleToStr(100.0 * gda_216[l_index_72], 1) + "%\n";
      if (l_index_72 == ArrayRange(gda_216, 0) - 1) {
         li_60 = ai_40;
         ls_64 = "Приоритет " + ai_44 
         + "\nЦелевая\n";
      }
      DrawLine(as_0 + " / " + ((l_index_72 + 1)), li_52, ad_16, li_56, ad_16 + (ad_28 - ad_16) * (1 - gda_216[l_index_72]), ls_64, li_60, TRUE, TRUE, ai_48);
   }
   return (0);
}

int DrawLine(string a_name_0, int a_datetime_8, double a_price_12, int a_datetime_20, double a_price_24, string a_text_32, color a_color_40, int a_bool_44, int a_bool_48, int a_width_52) {
   if (ObjectFind(a_name_0) == -1) ObjectCreate(a_name_0, OBJ_TREND, 0, a_datetime_8, a_price_12, a_datetime_20, a_price_24);
   ObjectSet(a_name_0, OBJPROP_TIME1, a_datetime_8);
   ObjectSet(a_name_0, OBJPROP_TIME2, a_datetime_20);
   ObjectSet(a_name_0, OBJPROP_PRICE1, a_price_12);
   ObjectSet(a_name_0, OBJPROP_PRICE2, a_price_24);
   ObjectSet(a_name_0, OBJPROP_WIDTH, a_width_52);
   ObjectSet(a_name_0, OBJPROP_BACK, a_bool_48);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_40);
   ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(a_name_0, OBJPROP_RAY, a_bool_44);
   ObjectSetText(a_name_0, a_text_32, 10, "Times New Roman", Green);
   return (0);
}

int CTF(double a_timeframe_0, double ad_8, int ai_16) {
   int li_ret_20;
   double l_timeframe_24 = g_timeframe_232;
   if (l_timeframe_24 == 0.0 || a_timeframe_0 == 0.0) return (iTime(g_symbol_224, a_timeframe_0, ad_8));
   if (ad_8 / (l_timeframe_24 / a_timeframe_0) + 2.0 * (a_timeframe_0 / l_timeframe_24) > Bars - 1 || l_timeframe_24 >= a_timeframe_0) return (iTime(g_symbol_224, a_timeframe_0, ad_8));
   for (int li_32 = 0; li_32 < Bars - 1; li_32++)
      if (iTime(g_symbol_224, a_timeframe_0, ad_8) > iTime(g_symbol_224, 0, li_32)) break;
   if (ai_16 == 1) return (iTime(g_symbol_224, 0, iLowest(NULL, 0, MODE_LOW, 2.0 * (a_timeframe_0 / l_timeframe_24), li_32 - a_timeframe_0 / l_timeframe_24)));
   if (ai_16 == 2) return (iTime(g_symbol_224, 0, iHighest(NULL, 0, MODE_HIGH, 2.0 * (a_timeframe_0 / l_timeframe_24), li_32 - a_timeframe_0 / l_timeframe_24)));
   return (li_ret_20);
}

bool TestPriority(double ad_0, double ad_8, double ad_16, double ad_24, double ad_32, double ad_40, double ad_48) {
   double ld_56;
   double ld_64;
   if (ad_0 - ad_16 == 0.0) return (FALSE);
   if (ad_24 > ad_8) {
      ld_56 = ad_24 - ad_8;
      ld_64 = ad_40 - ad_8;
   } else {
      ld_56 = ad_8 - ad_24;
      ld_64 = ad_8 - ad_40;
   }
   double ld_72 = ld_56 / (ad_0 - ad_16);
   double ld_80 = ld_72 * (ad_0 - ad_32) * (1 - ad_48);
   if (ld_64 < ld_80) return (TRUE);
   return (FALSE);
}

int PeriodToTF(int ai_0) {
   for (int l_index_4 = 0; l_index_4 < ArrayRange(gia_204, 0); l_index_4++)
      if (gia_204[l_index_4] == ai_0) break;
   return (l_index_4);
}

int BarConvert(int a_timeframe_0, int a_timeframe_4, int ai_8, int ai_12) {
   if (a_timeframe_4 == 0) return (ai_8);
   int li_unused_16 = gia_220[PeriodToTF(a_timeframe_4)];
   if (a_timeframe_4 == a_timeframe_0) return (ai_8);
   if (a_timeframe_4 > a_timeframe_0) return (iBarShift(g_symbol_224, a_timeframe_4, iTime(g_symbol_224, a_timeframe_0, ai_8), FALSE));
   int l_shift_20 = iBarShift(g_symbol_224, a_timeframe_4, iTime(g_symbol_224, a_timeframe_0, ai_8), FALSE);
   if (ai_12 < 0) return (iLowest(g_symbol_224, a_timeframe_4, MODE_LOW, (a_timeframe_0 / a_timeframe_4) << 1, l_shift_20 - a_timeframe_0 / a_timeframe_4));
   if (ai_12 > 0) return (iHighest(g_symbol_224, a_timeframe_4, MODE_HIGH, (a_timeframe_0 / a_timeframe_4) << 1, l_shift_20 - a_timeframe_0 / a_timeframe_4));
   return (ai_8);
}

int DeleteFans(int ai_0) {
   string l_name_4;
   int li_12 = 30;
   for (int li_16 = ai_0; li_16 < li_12; li_16++) {
      for (int l_count_20 = 0; l_count_20 < ArrayRange(gda_216, 0); l_count_20++) {
         l_name_4 = "Веер " + ((li_16 + 1)) + " / " + ((l_count_20 + 1));
         ObjectDelete(l_name_4);
      }
   }
   return (0);
}

int DeleteCorLine(int ai_0) {
   string l_name_4;
   int li_12 = 50;
   for (int li_16 = ai_0; li_16 < li_12; li_16++) {
      l_name_4 = "Коррекция " + ((li_16 + 1));
      ObjectDelete(l_name_4);
   }
   return (0);
}

int InitGlobalVariables() {
   Comment("Lhasa   &   Morin");
   g_symbol_224 = Symbol();
   g_timeframe_232 = Period();
   gia_208[0] = Level1;
   gia_208[1] = Level2;
   gia_208[2] = Level3;
   gia_208[3] = Level4;
   gia_208[4] = Level5;
   gia_208[5] = Level6;
   gia_208[6] = Level7;
   if (gi_164 > 7) gi_164 = 7;
   for (int l_index_0 = 0; l_index_0 < ArrayRange(gia_204, 0); l_index_0++) gia_220[l_index_0] = iBars(g_symbol_224, gia_204[l_index_0]);
   gd_156 = 4.0 * AverageBar(g_symbol_224, PERIOD_D1, 0, 100);
   string l_name_4 = "LastBar";
   gi_172 = TimeCurrent();
   if (ObjectFind(l_name_4) != -1) gi_172 = iTime(g_symbol_224, g_timeframe_232, iBarShift(g_symbol_224, g_timeframe_232, ObjectGet(l_name_4, OBJPROP_TIME1), FALSE) - 1) - 1;
   gi_168 = iBarShift(g_symbol_224, g_timeframe_232, gi_172, FALSE);
   return (0);
}

int DeleteClouds(int ai_0) {
   string l_name_4;
   int li_12 = ArrayRange(gda_188, 0);
   int li_16 = ArrayRange(gsa_200, 0);
   for (int li_20 = ai_0; li_20 < li_12; li_20++) {
      l_name_4 = "Cloud " + li_20;
      for (int l_index_24 = 0; l_index_24 < li_16; l_index_24++) {
         ObjectDelete(l_name_4);
         ObjectDelete(l_name_4 + " " + gsa_200[l_index_24]);
      }
      ObjectDelete("TimeZone Cloud " + li_20);
      ObjectDelete("TimeZone Purpose Cloud " + li_20);
      ObjectDelete("TimeZone Purpose Cloud " + li_20 + " pips");
      ObjectDelete(l_name_4 + " Rectangle");
   }
   return (0);
}

string PeriodToString(int ai_0) {
   if (ai_0 == 1) return ("M1");
   if (ai_0 == 5) return ("M5");
   if (ai_0 == 15) return ("M15");
   if (ai_0 == 30) return ("M30");
   if (ai_0 == 60) return ("H1");
   if (ai_0 == 240) return ("H4");
   if (ai_0 == 1440) return ("D1");
   if (ai_0 == 10080) return ("W1");
   if (ai_0 == 43200) return ("MN1");
   return ("");
}

Recommend