/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website:  ht T P :/ / W w w . mE t AQ u OT e s . n e t
   E-mail : s U P p o r T @ MET A q UoTES. neT
*/
#property copyright "Copyright 2012, Top Lessons in Forex"
#property link      "http://www.toplessons.in/forex"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Sienna
#property indicator_color2 Yellow
#property indicator_color3 Gray
#property indicator_color4 LightBlue
#property indicator_color5 Green
#property indicator_color6 White
#property indicator_color7 LightBlue
#property indicator_color8 Green

#import "kernel32.dll"
   void GetLocalTime(int& a0[]);
   void GetSystemTime(int& a0[]);
   int GetTimeZoneInformation(int& a0[]);
   bool SystemTimeToTzSpecificLocalTime(int& a0[], int& a1[], int& a2[]);
#import

int Gia_76[43];
int Gia_80[43];
int Gia_84[43];
int Gia_88[43];
int Gia_92[43];
int Gia_96[43];
int Gia_100[43];
int Gia_104[43];
int Gia_108[43];
extern string comm = "optional manual time start";
extern string sydney_hour = "";
int Gi_128 = 8;
int Gi_132 = 17;
int Gi_136 = 8;
int Gi_unused_140 = 16;
int Gi_144;
int Gi_148;
int Gi_152;
int Gi_156;
int Gi_160;
int Gi_164;
int Gi_168;
int Gi_172;
int Gi_176;
int Gi_180;
int Gi_184;
int G_datetime_188;
extern int maxlookback = 1440;
extern bool show.sydney = TRUE;
extern bool show.tokyo = TRUE;
extern bool show.frankfurt = TRUE;
extern bool show.london = TRUE;
extern bool show.usa = TRUE;
extern bool show.emo = TRUE;
extern bool show.londonclose = TRUE;
extern bool show.usaclose = FALSE;
extern bool show.verticalMarkers = FALSE;
extern bool show.labels = FALSE;
extern color vlinecolor = White;
extern bool historicals = FALSE;
double G_ibuf_244[];
double G_ibuf_248[];
double G_ibuf_252[];
double G_ibuf_256[];
double G_ibuf_260[];
double G_ibuf_264[];
double G_ibuf_268[];
double G_ibuf_272[];
datetime G_time_276 = 0;

// 80D469BB03412C764655C68EF76E167D
void f0_3() {
   f0_11(Gia_76, Gia_80, Gia_84, Gia_88, Gia_92, Gia_96, Gia_100, Gia_104, Gia_108);
}

// F1BB2FB28E0FC5DBB873D3134F65F0F5
int f0_9(int Ai_0) {
   int Li_ret_4 = iTime(NULL, PERIOD_D1, iBarShift(NULL, PERIOD_D1, Ai_0));
   Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_156;
   if (Li_ret_4 + 86400 <= Ai_0) Li_ret_4 += 86400;
   if (sydney_hour != "") Li_ret_4 = StrToTime(TimeYear(Ai_0) + "." + TimeMonth(Ai_0) + "." + TimeDay(Ai_0) + " " + sydney_hour);
   if (Li_ret_4 > Ai_0) Li_ret_4 -= 86400;
   if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
   return (Li_ret_4);
}

// 30A8DD6477161F6BC6022244BA274218
int f0_1(int Ai_0) {
   int Li_ret_4 = iTime(NULL, PERIOD_D1, iBarShift(NULL, PERIOD_D1, Ai_0));
   Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_156;
   if (Li_ret_4 + 86400 <= Ai_0) Li_ret_4 += 86400;
   if (sydney_hour != "") Li_ret_4 = StrToTime(TimeYear(Ai_0) + "." + TimeMonth(Ai_0) + "." + TimeDay(Ai_0) + " " + sydney_hour);
   if (Li_ret_4 > Ai_0) Li_ret_4 -= 86400;
   if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
   int Li_8 = Li_ret_4;
   if (TimeDayOfWeek(Li_ret_4) == 0) {
      Li_ret_4 = iTime(NULL, PERIOD_D1, iBarShift(NULL, PERIOD_D1, Ai_0));
      Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_164;
      if (Li_ret_4 + 86400 <= Ai_0) Li_ret_4 += 86400;
      if (Li_ret_4 > Ai_0) Li_ret_4 -= 86400;
      if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
      if (iBarShift(NULL, PERIOD_H1, Li_ret_4, TRUE) == -1) {
         for (Li_ret_4 = Li_8; iBarShift(NULL, PERIOD_H1, Li_ret_4, TRUE) == -1 && TimeDayOfWeek(Li_ret_4) != 4; Li_ret_4 -= 86400) {
         }
         if (TimeDayOfWeek(Li_ret_4) == 5 && TimeHour(Li_ret_4) > 12) Li_ret_4 -= 86400;
      }
   } else
      if (TimeDayOfWeek(Li_ret_4) == 5 && TimeHour(Li_ret_4) > 12) Li_ret_4 -= 86400;
   return (Li_ret_4);
}

// EE7BF9D10D4C319F770A495B46E5BC84
int f0_8(int Ai_0) {
   int Li_ret_4 = iTime(NULL, PERIOD_W1, iBarShift(NULL, PERIOD_W1, Ai_0));
   Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_156;
   if (Li_ret_4 + 604800 <= Ai_0) Li_ret_4 += 604800;
   if (Li_ret_4 > Ai_0) Li_ret_4 -= 604800;
   if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
   if (TimeDayOfWeek(Li_ret_4) == 6 || TimeDayOfWeek(Li_ret_4) == 0) {
      Li_ret_4 = iTime(NULL, PERIOD_W1, iBarShift(NULL, PERIOD_W1, Ai_0));
      Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_164;
      if (Li_ret_4 + 604800 <= Ai_0) Li_ret_4 += 604800;
      if (Li_ret_4 > Ai_0) Li_ret_4 -= 604800;
      if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
      if (iBarShift(NULL, PERIOD_H1, Li_ret_4, TRUE) == -1) {
         while (iBarShift(NULL, PERIOD_H1, Li_ret_4, TRUE) == -1 && TimeDayOfWeek(Li_ret_4) != 2) Li_ret_4 += 86400;
         if (Li_ret_4 > Ai_0) return (Li_ret_4 - 604800);
      }
   }
   return (Li_ret_4);
}

// E98651D565D1700A4A6D92916557D7A6
int f0_7(int Ai_0) {
   int Li_ret_4 = iTime(NULL, PERIOD_MN1, iBarShift(NULL, PERIOD_MN1, Ai_0));
   Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_156;
   if (Li_ret_4 + 2592000 <= Ai_0) Li_ret_4 += 2592000;
   if (Li_ret_4 > Ai_0) Li_ret_4 -= 2592000;
   if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
   if (TimeDayOfWeek(Li_ret_4) == 6 || TimeDayOfWeek(Li_ret_4) == 0) {
      Li_ret_4 = iTime(NULL, PERIOD_MN1, iBarShift(NULL, PERIOD_MN1, Ai_0));
      Li_ret_4 += 3600 * Gi_136 + Gi_144 - Gi_164;
      if (Li_ret_4 + 2592000 <= Ai_0) Li_ret_4 += 2592000;
      if (Li_ret_4 > Ai_0) Li_ret_4 -= 2592000;
      if (TimeMinute(Li_ret_4) > 57) Li_ret_4 = Li_ret_4 - 60 * TimeMinute(Li_ret_4) + 3600;
      if (iBarShift(NULL, PERIOD_H1, Li_ret_4, TRUE) == -1) {
         while (iBarShift(NULL, PERIOD_H1, Li_ret_4, TRUE) == -1 && TimeDayOfWeek(Li_ret_4) != 2) Li_ret_4 += 86400;
         if (Li_ret_4 > Ai_0) return (Li_ret_4 - 2592000);
      }
   }
   return (Li_ret_4);
}

// 91028CFF58F4204C414A9DEC890BDFE5
int f0_4(string A_symbol_0, int A_timeframe_8, int Ai_12) {
   if (A_timeframe_8 < PERIOD_H4) return (iTime(A_symbol_0, A_timeframe_8, iBarShift(A_symbol_0, A_timeframe_8, Ai_12)));
   int Li_ret_16 = f0_1(Ai_12);
   if (A_timeframe_8 == PERIOD_D1) return (Li_ret_16);
   int Li_ret_20 = Ai_12 - 60 * TimeMinute(Ai_12) - TimeSeconds(Ai_12);
   int hour_24 = TimeHour(Li_ret_16);
   if (TimeHour(f0_9(Ai_12)) == 0) return (iTime(A_symbol_0, A_timeframe_8, iBarShift(A_symbol_0, A_timeframe_8, Ai_12)));
   if (A_timeframe_8 == PERIOD_H4) {
      hour_24 = TimeHour(f0_9(Ai_12));
      for (int Li_28 = MathAbs(TimeHour(Li_ret_20) - hour_24); Li_28 % 4 != 0; Li_28 = MathAbs(TimeHour(Li_ret_20) - hour_24)) Li_ret_20 -= 3600;
      return (Li_ret_20);
   }
   if (A_timeframe_8 == PERIOD_W1) return (f0_8(Ai_12));
   return (f0_7(Ai_12));
}

// F353D04F1B330DBDD560DC9FBB76420C
double f0_10(string A_symbol_0, int A_timeframe_8, int Ai_12) {
   double iopen_16 = iOpen(A_symbol_0, A_timeframe_8, iBarShift(A_symbol_0, A_timeframe_8, Ai_12));
   if (A_timeframe_8 < PERIOD_H4) return (iopen_16);
   Ai_12 = f0_4(A_symbol_0, A_timeframe_8, Ai_12);
   if (A_timeframe_8 == PERIOD_H4) while (iBarShift(A_symbol_0, PERIOD_H1, Ai_12, TRUE) == -1 && TimeDayOfWeek(Ai_12) > 4 || TimeDayOfWeek(Ai_12) == 0) Ai_12 -= 14400;
   int shift_24 = iBarShift(A_symbol_0, PERIOD_H1, Ai_12);
   return (iOpen(A_symbol_0, PERIOD_H1, shift_24));
}

// 54387F5BF32A9F5E721CCA0681DD8280
void f0_2() {
   int Lia_0[4];
   int Lia_4[4];
   int Lia_8[4];
   int Lia_12[4];
   int Lia_16[4];
   int Lia_20[4];
   int Lia_24[4];
   int Lia_28[4];
   int Lia_32[4];
   int Lia_36[4];
   int Li_40;
   int file_44;
   int Li_48;
   if (!IsDllsAllowed()) {
      if (TimeCurrent() - G_datetime_188 >= 7) {
         G_datetime_188 = TimeCurrent();
         Alert(WindowExpertName(), ": DLLs are disabled. To enable, select \'Allow DLL Imports\' in the Common Tab of the Expert Advisor!");
      }
   } else {
      G_datetime_188 = TimeCurrent();
      GetLocalTime(Lia_0);
      Gi_184 = f0_6(Lia_0);
      Gi_144 = TimeCurrent();
      Li_40 = 0;
      GetSystemTime(Lia_4);
      Gi_148 = f0_6(Lia_4) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_80, Lia_4, Lia_8);
      Gi_152 = f0_6(Lia_8) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_92, Lia_4, Lia_20);
      Gi_156 = f0_6(Lia_20) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_84, Lia_4, Lia_12);
      Gi_160 = f0_6(Lia_12) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_88, Lia_4, Lia_16);
      Gi_164 = f0_6(Lia_16) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_96, Lia_4, Lia_24);
      Gi_168 = f0_6(Lia_24) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_100, Lia_4, Lia_28);
      Gi_172 = f0_6(Lia_28) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_104, Lia_4, Lia_32);
      Gi_176 = f0_6(Lia_32) + Li_40;
      SystemTimeToTzSpecificLocalTime(Gia_108, Lia_4, Lia_36);
      Gi_180 = f0_6(Lia_36) + Li_40;
      if (TimeMinute(Gi_156) != TimeMinute(Gi_144)) {
         if (TimeMinute(Gi_144) > 50 && TimeMinute(Gi_156) < 10) Gi_144 = Gi_144 - 60 * TimeMinute(Gi_144) - TimeSeconds(Gi_144) + 3600 + 60 * TimeMinute(Gi_156) + TimeSeconds(Gi_156);
         else Gi_144 = Gi_144 - 60 * TimeMinute(Gi_144) - TimeSeconds(Gi_144) + 60 * TimeMinute(Gi_156) + TimeSeconds(Gi_156);
      }
      if (TimeDayOfWeek(Gi_148) > 4 || TimeDayOfWeek(Gi_148) == 0) {
         file_44 = FileOpen("real_timeframe.dat", FILE_BIN|FILE_READ);
         if (file_44 < 1) Print("File real_timeframe.dat not found, the last error is ", GetLastError());
         else {
            Li_48 = FileReadInteger(file_44, SHORT_VALUE);
            Gi_144 = Gi_156 - 3600 * Li_48;
            FileClose(file_44);
         }
      } else {
         file_44 = FileOpen("real_timeframe.dat", FILE_BIN|FILE_WRITE);
         if (file_44 < 1) Print("File real_timeframe.dat not found, the last error is ", GetLastError());
         else {
            FileWriteInteger(file_44, (Gi_156 - Gi_144) / 3600, SHORT_VALUE);
            FileClose(file_44);
         }
      }
   }
}

// C248C34F8D287A6A2F05C377B9F06428
string f0_5(int Ai_0, int Ai_4, int Ai_8, int Ai_12, int Ai_16, int Ai_20) {
   string Ls_24 = Ai_4 + 100;
   Ls_24 = StringSubstr(Ls_24, 1);
   string Ls_32 = Ai_8 + 100;
   Ls_32 = StringSubstr(Ls_32, 1);
   string Ls_40 = Ai_12 + 100;
   Ls_40 = StringSubstr(Ls_40, 1);
   string Ls_48 = Ai_16 + 100;
   Ls_48 = StringSubstr(Ls_48, 1);
   string Ls_56 = Ai_20 + 100;
   Ls_56 = StringSubstr(Ls_56, 1);
   return (StringConcatenate(Ai_0, ".", Ls_24, ".", Ls_32, " ", Ls_40, ":", Ls_48, ":", Ls_56));
}

// D686A33191E6564C19CE2A3F4C016F18
int f0_6(int Aia_0[4]) {
   int str2time_44;
   int Li_4 = Aia_0[0] & 65535;
   int Li_8 = Aia_0[0] >> 16;
   int Li_16 = Aia_0[1] >> 16;
   int Li_20 = Aia_0[2] & 65535;
   int Li_24 = Aia_0[2] >> 16;
   int Li_28 = Aia_0[3] & 65535;
   int Li_32 = Aia_0[3] >> 16;
   string Ls_36 = f0_5(Li_4, Li_8, Li_16, Li_20, Li_24, Li_28);
   str2time_44 = StrToTime(Ls_36);
   return (str2time_44);
}

// F64EB7DDFF4E55448F40C6CD0AA3B080
void f0_11(int Aia_0[43], int &Aia_4[43], int &Aia_8[43], int &Aia_12[43], int &Aia_16[43], int &Aia_20[43], int &Aia_24[43], int &Aia_28[43], int &Aia_32[43]) {
   int Li_36 = GetTimeZoneInformation(Aia_0);
   Aia_4[0] = 300;
   Aia_4[17] = 720896;
   Aia_4[18] = 65536;
   Aia_4[19] = 2;
   Aia_4[20] = 0;
   Aia_4[21] = 0;
   Aia_4[38] = 196608;
   Aia_4[39] = 131072;
   Aia_4[40] = 2;
   Aia_4[41] = 0;
   Aia_4[42] = -60;
   Aia_8[0] = 0;
   Aia_8[17] = 655360;
   Aia_8[18] = 327680;
   Aia_8[19] = 2;
   Aia_8[20] = 0;
   Aia_8[21] = 0;
   Aia_8[38] = 196608;
   Aia_8[39] = 327680;
   Aia_8[40] = 1;
   Aia_8[41] = 0;
   Aia_8[42] = -60;
   Aia_12[0] = -540;
   Aia_12[17] = 0;
   Aia_12[18] = 0;
   Aia_12[19] = 0;
   Aia_12[20] = 0;
   Aia_12[21] = 0;
   Aia_12[38] = 0;
   Aia_12[39] = 0;
   Aia_12[40] = 0;
   Aia_12[41] = 0;
   Aia_12[42] = 0;
   Aia_16[0] = -600;
   Aia_16[17] = 262144;
   Aia_16[18] = 65536;
   Aia_16[19] = 3;
   Aia_16[20] = 0;
   Aia_16[21] = 0;
   Aia_16[38] = 655360;
   Aia_16[39] = 65536;
   Aia_16[40] = 2;
   Aia_16[41] = 0;
   Aia_16[42] = -60;
   Aia_20[0] = -720;
   Aia_20[17] = 262144;
   Aia_20[18] = 65536;
   Aia_20[19] = 3;
   Aia_20[20] = 0;
   Aia_20[21] = 0;
   Aia_20[38] = 589824;
   Aia_20[39] = 327680;
   Aia_20[40] = 2;
   Aia_20[41] = 0;
   Aia_20[42] = -60;
   ArrayCopy(Aia_24, Aia_8);
   Aia_24[0] = -180;
   ArrayCopy(Aia_28, Aia_8);
   Aia_28[0] = -60;
   ArrayCopy(Aia_32, Aia_4);
   Aia_32[0] = 480;
}

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   f0_3();
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, G_ibuf_244);
   SetIndexLabel(0, "Sydney");
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, G_ibuf_248);
   SetIndexLabel(1, "Tokyo");
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, G_ibuf_252);
   SetIndexLabel(2, "Frankfurt");
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, G_ibuf_256);
   SetIndexLabel(3, "London");
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, G_ibuf_260);
   SetIndexLabel(4, "USA");
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, G_ibuf_264);
   SetIndexLabel(5, "US Equity Markets");
   SetIndexStyle(6, DRAW_LINE);
   SetIndexBuffer(6, G_ibuf_268);
   SetIndexLabel(6, "London Closing Bell");
   SetIndexStyle(7, DRAW_LINE);
   SetIndexBuffer(7, G_ibuf_272);
   SetIndexLabel(7, "USA Closing Bell");
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   ObjectDelete("sydney_open_time_l");
   ObjectDelete("tokyo_open_time_l");
   ObjectDelete("frank_open_time_l");
   ObjectDelete("london_open_time_l");
   ObjectDelete("usa_open_time_l");
   ObjectDelete("usem_open_time_l");
   ObjectDelete("london_close_time_l");
   ObjectDelete("usa_close_time_l");
   return (0);
}

// 1093464FCDFB80BE70432E26976AF888
void f0_0() {
   if (ObjectFind("tl_powered") != 0) {
      ObjectCreate("tl_powered", OBJ_LABEL, 0, 0, 0);
      ObjectSetText("tl_powered", "© " + TimeYear(TimeCurrent()) + " TopLessons.In/Forex", 7, "Arial", Gold);
      ObjectSet("tl_powered", OBJPROP_CORNER, 2);
      ObjectSet("tl_powered", OBJPROP_XDISTANCE, 10);
      ObjectSet("tl_powered", OBJPROP_YDISTANCE, 10);
   }
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_4;
   int Li_8;
   double Ld_unused_12;
   string name_20;
   int Li_28;
   int Li_32;
   int datetime_40;
   int Li_44;
   int Li_48;
   int Li_52;
   int Li_56;
   int Li_60;
   int Li_64;
   int Li_68;
   int Li_0 = Bars;
   if (Li_0 > maxlookback) Li_0 = maxlookback;
   if (Li_0 > Bars) Li_0 = Bars / 2;
   if (G_time_276 != Time[0]) {
      f0_0();
      ArrayInitialize(G_ibuf_244, 0);
      ArrayInitialize(G_ibuf_248, 0);
      ArrayInitialize(G_ibuf_252, 0);
      ArrayInitialize(G_ibuf_256, 0);
      ArrayInitialize(G_ibuf_260, 0);
      ArrayInitialize(G_ibuf_264, 0);
      ArrayInitialize(G_ibuf_268, 0);
      ArrayInitialize(G_ibuf_272, 0);
      G_time_276 = Time[0];
      f0_2();
      Li_4 = f0_1(Time[0]);
      Li_8 = WindowFirstVisibleBar();
      Ld_unused_12 = High[iHighest(NULL, 0, MODE_HIGH, Li_8)];
      name_20 = "";
      Li_28 = 558239400;
      Li_32 = 0;
      for (int Li_36 = 0; Li_36 <= Li_0; Li_36++) {
         datetime_40 = f0_1(Time[Li_36]);
         if (show.sydney) {
            if (Li_36 == 0) {
               if (datetime_40 - TimeCurrent() + 86400 <= 900 && datetime_40 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/sydney_open_15m.wav");
               else
                  if (datetime_40 - TimeCurrent() + 86400 <= 300 && datetime_40 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/sydney_open_5m.wav");
            }
            G_ibuf_244[Li_36] = f0_10(Symbol(), PERIOD_H1, datetime_40);
            if (datetime_40 > Li_28) {
               name_20 = "sydney_open_time" + datetime_40;
               Li_28 = datetime_40;
               Li_32 = 0;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("sydney_open_time" + datetime_40) != 0) ObjectDelete("sydney_open_time" + datetime_40);
               ObjectCreate("sydney_open_time" + datetime_40, OBJ_VLINE, 0, datetime_40, 0, 0);
               ObjectSet("sydney_open_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("sydney_open_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("sydney_open_time_l") != 0) ObjectDelete("sydney_open_time_l");
               ObjectCreate("sydney_open_time_l", OBJ_TEXT, 0, datetime_40 + 900, G_ibuf_244[Li_36]);
               ObjectSet("sydney_open_time_l", OBJPROP_TIME1, datetime_40 + 900);
               ObjectSet("sydney_open_time_l", OBJPROP_PRICE1, G_ibuf_244[Li_36]);
               ObjectSetText("sydney_open_time_l", "Sydney", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_244[Li_36] != G_ibuf_244[0]) G_ibuf_244[Li_36] = EMPTY_VALUE;
         if (TimeDayOfWeek(f0_9(Time[Li_36])) == 0) datetime_40 = datetime_40 + Gi_164 - Gi_156;
         Li_44 = datetime_40 - Gi_164 + Gi_156;
         if (Li_44 > Time[Li_36]) Li_44 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_44, TRUE) == -1) Li_44 -= 172800;
         Li_48 = datetime_40 - Gi_176 + Gi_156;
         if (Li_48 > Time[Li_36]) Li_48 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_48, TRUE) == -1) Li_48 -= 172800;
         Li_52 = datetime_40 - Gi_160 + Gi_156;
         if (Li_52 > Time[Li_36]) Li_52 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_52, TRUE) == -1) Li_52 -= 172800;
         Li_56 = datetime_40 - Gi_152 + Gi_156;
         if (Li_56 > Time[Li_36]) Li_56 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_56, TRUE) == -1) Li_56 -= 172800;
         Li_60 = Li_56 + 5400;
         if (Li_60 > Time[Li_36]) Li_60 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_60, TRUE) == -1) Li_60 -= 172800;
         Li_64 = Li_52 + 3600 * (Gi_132 - Gi_128 - 1);
         if (Li_64 > Time[Li_36]) Li_64 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_64, TRUE) == -1) Li_64 -= 172800;
         Li_68 = Li_56 + 3600 * (Gi_132 - Gi_128 - 1);
         if (Li_68 > Time[Li_36]) Li_68 -= 86400;
         if (iBarShift(NULL, PERIOD_H1, Li_68, TRUE) == -1) Li_68 -= 172800;
         if (TimeDayOfWeek(f0_9(Time[Li_36])) == 0) datetime_40 = datetime_40 - Gi_164 + Gi_156;
         if (show.tokyo) {
            if (Li_36 == 0) {
               if (Li_44 - TimeCurrent() + 86400 <= 900 && Li_44 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/tokyo_open_15m.wav");
               else
                  if (Li_44 - TimeCurrent() + 86400 <= 300 && Li_44 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/tokyo_open_5m.wav");
            }
            G_ibuf_248[Li_36] = f0_10(Symbol(), PERIOD_H1, Li_44);
            if (Li_44 > Li_28) {
               name_20 = "tokyo_open_time" + datetime_40;
               Li_28 = Li_44;
               Li_32 = 1;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("tokyo_open_time" + datetime_40) != 0) ObjectDelete("tokyo_open_time" + datetime_40);
               ObjectCreate("tokyo_open_time" + datetime_40, OBJ_VLINE, 0, Li_44, 0, 0);
               ObjectSet("tokyo_open_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("tokyo_open_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("tokyo_open_time_l") != 0) ObjectDelete("tokyo_open_time_l");
               ObjectCreate("tokyo_open_time_l", OBJ_TEXT, 0, Li_44 + 900, G_ibuf_248[Li_36]);
               ObjectSet("tokyo_open_time_l", OBJPROP_TIME1, Li_44 + 900);
               ObjectSet("tokyo_open_time_l", OBJPROP_PRICE1, G_ibuf_248[Li_36]);
               ObjectSetText("tokyo_open_time_l", "Tokyo", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_248[Li_36] != G_ibuf_248[0]) G_ibuf_248[Li_36] = EMPTY_VALUE;
         if (show.frankfurt) {
            if (Li_36 == 0) {
               if (Li_48 - TimeCurrent() + 86400 <= 900 && Li_48 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/frankfurt_open_15m.wav");
               else
                  if (Li_48 - TimeCurrent() + 86400 <= 300 && Li_48 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/frankfurt_open_5m.wav");
            }
            G_ibuf_252[Li_36] = f0_10(Symbol(), PERIOD_H1, Li_48);
            if (Li_48 > Li_28) {
               name_20 = "frank_open_time" + datetime_40;
               Li_28 = Li_48;
               Li_32 = 2;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("frank_open_time" + datetime_40) != 0) ObjectDelete("frank_open_time" + datetime_40);
               ObjectCreate("frank_open_time" + datetime_40, OBJ_VLINE, 0, Li_48, 0, 0);
               ObjectSet("frank_open_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("frank_open_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("frank_open_time_l") != 0) ObjectDelete("frank_open_time_l");
               ObjectCreate("frank_open_time_l", OBJ_TEXT, 0, Li_48 + 900, G_ibuf_252[Li_36]);
               ObjectSet("frank_open_time_l", OBJPROP_TIME1, Li_48 + 900);
               ObjectSet("frank_open_time_l", OBJPROP_PRICE1, G_ibuf_252[Li_36]);
               ObjectSetText("frank_open_time_l", "Frankfurt", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_252[Li_36] != G_ibuf_252[0]) G_ibuf_252[Li_36] = EMPTY_VALUE;
         if (show.london) {
            if (Li_36 == 0) {
               if (Li_52 - TimeCurrent() + 86400 <= 900 && Li_52 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/london_open_15m.wav");
               else
                  if (Li_52 - TimeCurrent() + 86400 <= 300 && Li_52 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/london_open_5m.wav");
            }
            G_ibuf_256[Li_36] = f0_10(Symbol(), PERIOD_H1, Li_52);
            if (Li_52 > Li_28) {
               name_20 = "london_open_time" + datetime_40;
               Li_28 = Li_52;
               Li_32 = 3;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("london_open_time" + datetime_40) != 0) ObjectDelete("london_open_time" + datetime_40);
               ObjectCreate("london_open_time" + datetime_40, OBJ_VLINE, 0, Li_52, 0, 0);
               ObjectSet("london_open_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("london_open_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("london_open_time_l") != 0) ObjectDelete("london_open_time_l");
               ObjectCreate("london_open_time_l", OBJ_TEXT, 0, Li_52 + 900, G_ibuf_256[Li_36]);
               ObjectSet("london_open_time_l", OBJPROP_TIME1, Li_52 + 900);
               ObjectSet("london_open_time_l", OBJPROP_PRICE1, G_ibuf_256[Li_36]);
               ObjectSetText("london_open_time_l", "London", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_256[Li_36] != G_ibuf_256[0]) G_ibuf_256[Li_36] = EMPTY_VALUE;
         if (show.usa) {
            if (Li_36 == 0) {
               if (Li_56 - TimeCurrent() + 86400 <= 900 && Li_56 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/usa_open_15m.wav");
               else
                  if (Li_56 - TimeCurrent() + 86400 <= 300 && Li_56 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/usa_open_5m.wav");
            }
            G_ibuf_260[Li_36] = f0_10(Symbol(), PERIOD_H1, Li_56);
            if (Li_56 > Li_28) {
               name_20 = "usa_open_time" + datetime_40;
               Li_28 = Li_56;
               Li_32 = 4;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("usa_open_time" + datetime_40) != 0) ObjectDelete("usa_open_time" + datetime_40);
               ObjectCreate("usa_open_time" + datetime_40, OBJ_VLINE, 0, Li_56, 0, 0);
               ObjectSet("usa_open_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("usa_open_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("usa_open_time_l") != 0) ObjectDelete("usa_open_time_l");
               ObjectCreate("usa_open_time_l", OBJ_TEXT, 0, Li_56 + 900, G_ibuf_260[Li_36]);
               ObjectSet("usa_open_time_l", OBJPROP_TIME1, Li_56 + 900);
               ObjectSet("usa_open_time_l", OBJPROP_PRICE1, G_ibuf_260[Li_36]);
               ObjectSetText("usa_open_time_l", "New York", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_260[Li_36] != G_ibuf_260[0]) G_ibuf_260[Li_36] = EMPTY_VALUE;
         if (show.emo) {
            if (Li_36 == 0) {
               if (Li_60 - TimeCurrent() + 86400 <= 900 && Li_60 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/usem_open_15m.wav");
               else
                  if (Li_60 - TimeCurrent() + 86400 <= 300 && Li_60 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/usem_open_5m.wav");
            }
            G_ibuf_264[Li_36] = f0_10(Symbol(), PERIOD_M30, Li_60);
            if (Li_60 > Li_28) {
               name_20 = "usem_open_time" + datetime_40;
               Li_28 = Li_60;
               Li_32 = 5;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("usem_open_time" + datetime_40) != 0) ObjectDelete("usem_open_time" + datetime_40);
               ObjectCreate("usem_open_time" + datetime_40, OBJ_VLINE, 0, Li_60, 0, 0);
               ObjectSet("usem_open_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("usem_open_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("usem_open_time_l") != 0) ObjectDelete("usem_open_time_l");
               ObjectCreate("usem_open_time_l", OBJ_TEXT, 0, Li_60 + 900, G_ibuf_264[Li_36]);
               ObjectSet("usem_open_time_l", OBJPROP_TIME1, Li_60 + 900);
               ObjectSet("usem_open_time_l", OBJPROP_PRICE1, G_ibuf_264[Li_36]);
               ObjectSetText("usem_open_time_l", "US Equity Market", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_264[Li_36] != G_ibuf_264[0]) G_ibuf_264[Li_36] = EMPTY_VALUE;
         if (show.londonclose) {
            if (Li_36 == 0) {
               if (Li_64 - TimeCurrent() + 86400 <= 900 && Li_64 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/london_close_15m.wav");
               else
                  if (Li_64 - TimeCurrent() + 86400 <= 300 && Li_64 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/london_close_5m.wav");
            }
            G_ibuf_268[Li_36] = f0_10(Symbol(), PERIOD_H1, Li_64);
            if (Li_64 > Li_28) {
               name_20 = "london_close_time" + datetime_40;
               Li_28 = Li_64;
               Li_32 = 6;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("london_close_time" + datetime_40) != 0) ObjectDelete("london_close_time" + datetime_40);
               ObjectCreate("london_close_time" + datetime_40, OBJ_VLINE, 0, Li_64, 0, 0);
               ObjectSet("london_close_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("london_close_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("london_close_time_l") != 0) ObjectDelete("london_close_time_l");
               ObjectCreate("london_close_time_l", OBJ_TEXT, 0, Li_64 + 900, G_ibuf_268[Li_36]);
               ObjectSet("london_close_time_l", OBJPROP_TIME1, Li_64 + 900);
               ObjectSet("london_close_time_l", OBJPROP_PRICE1, G_ibuf_268[Li_36]);
               ObjectSetText("london_close_time_l", "London Close", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_268[Li_36] != G_ibuf_268[0]) G_ibuf_268[Li_36] = EMPTY_VALUE;
         if (show.usaclose) {
            if (Li_36 == 0) {
               if (Li_68 - TimeCurrent() + 86400 <= 900 && Li_68 - TimeCurrent() + 86400 >= 840) PlaySound("brilliant_charts/sessions/usa_close_15m.wav");
               else
                  if (Li_68 - TimeCurrent() + 86400 <= 300 && Li_68 - TimeCurrent() + 86400 >= 240) PlaySound("brilliant_charts/sessions/usa_close_5m.wav");
            }
            G_ibuf_272[Li_36] = f0_10(Symbol(), PERIOD_H1, Li_68);
            if (Li_68 > Li_28) {
               name_20 = "usa_close_time" + datetime_40;
               Li_28 = datetime_40;
               Li_32 = 7;
            }
            if (show.verticalMarkers && historicals || datetime_40 == Li_4) {
               if (ObjectFind("usa_close_time" + datetime_40) != 0) ObjectDelete("usa_close_time" + datetime_40);
               ObjectCreate("usa_close_time" + datetime_40, OBJ_VLINE, 0, Li_68, 0, 0);
               ObjectSet("usa_close_time" + datetime_40, OBJPROP_COLOR, vlinecolor);
               ObjectSet("usa_close_time" + datetime_40, OBJPROP_BACK, TRUE);
            }
            if (show.labels && Li_36 == 0) {
               if (ObjectFind("usa_close_time_l") != 0) ObjectDelete("usa_close_time_l");
               ObjectCreate("usa_close_time_l", OBJ_TEXT, 0, Li_68 + 900, G_ibuf_272[Li_36]);
               ObjectSet("usa_close_time_l", OBJPROP_TIME1, Li_68 + 900);
               ObjectSet("usa_close_time_l", OBJPROP_PRICE1, G_ibuf_272[Li_36]);
               ObjectSetText("usa_close_time_l", "New York Close", 10, "Arial", vlinecolor);
            }
         }
         if ((!historicals) && G_ibuf_272[Li_36] != G_ibuf_272[0]) G_ibuf_272[Li_36] = EMPTY_VALUE;
      }
      ObjectSet(name_20, OBJPROP_WIDTH, 3);
      for (Li_36 = 0; Li_36 < 8; Li_36++) SetIndexStyle(Li_36, DRAW_LINE, EMPTY, 1);
      SetIndexStyle(Li_32, DRAW_LINE, EMPTY, 5);
   }
   return (0);
}
