

#property copyright "Copyright © 2008, NuckingFuts"
#property link      "www.forexfactory.com"

#property indicator_chart_window

extern int NumberOfBars = 500;
extern string Note = "0 means Display all bars";
extern int Sydney_Open = 20;
extern int Tokyo_Open = 23;
extern int Frank_Open = 5;
extern int London_Open = 7;
extern int London_Close = 15;
extern int NY_Open = 11;
extern color SydneyColor = Tomato;
extern color TokyoColor = Fuchsia;
extern color FrankColor = Lime;
extern color LondonColor = Yellow;
extern color NYColor = DeepSkyBlue;
extern int LabelFontSize = 12;
extern bool ShowTexts = false;
int gi_136 = 0;

int init() {
   return (0);
}

int deinit() {
   string ls_0;
   bool li_8;
   while (true) {
      li_8 = TRUE;
      for (int li_12 = 0; li_12 < ObjectsTotal(); li_12++) {
         ls_0 = ObjectName(li_12);
         if (StringSubstr(ls_0, 3, 4) == "Open") ObjectDelete(ls_0);
      }
      for (int li_16 = 0; li_16 < ObjectsTotal(); li_16++) {
         ls_0 = ObjectName(li_16);
         if (StringSubstr(ls_0, 3, 4) == "Open") li_8 = FALSE;
      }
      if (!(li_8)) continue;
      break;
   }
   return (0);
}

int start() {
   double ld_0;
   string ls_8;
   int li_20;
   if (Period() > PERIOD_H1) return (0);
   int li_24 = IndicatorCounted();
   if (li_24 > 0) li_24--;
   if (NumberOfBars == 0) NumberOfBars = Bars - li_24;
   int li_16 = NumberOfBars;
   for (int li_28 = 0; li_28 < li_16; li_28++) {
      ls_8 = TimeToStr(iTime(Symbol(), PERIOD_H1, li_28));
      li_20 = TimeHour(iTime(Symbol(), PERIOD_H1, li_28));
      if (li_20 == Sydney_Open && gi_136 != iTime(Symbol(), PERIOD_H1, li_28)) {
         ld_0 = iOpen(Symbol(), PERIOD_H1, li_28);
         DrawOpenLine("SydOpen" + ls_8, "Sydney Open", ls_8, ld_0);
         gi_136 = iTime(Symbol(), PERIOD_H1, li_28);
      }
      if (li_20 == Tokyo_Open && gi_136 != iTime(Symbol(), PERIOD_H1, li_28)) {
         ld_0 = iOpen(Symbol(), PERIOD_H1, li_28);
         DrawOpenLine("TokOpen" + ls_8, "Tokyo Open", ls_8, ld_0);
         gi_136 = iTime(Symbol(), PERIOD_H1, li_28);
      }
      if (li_20 == Frank_Open && gi_136 != iTime(Symbol(), PERIOD_H1, li_28)) {
         ld_0 = iOpen(Symbol(), PERIOD_H1, li_28);
         DrawOpenLine("FrkOpen" + ls_8, "EURO Open", ls_8, ld_0);
         gi_136 = iTime(Symbol(), PERIOD_H1, li_28);
      }
      if (li_20 == London_Open && gi_136 != iTime(Symbol(), PERIOD_H1, li_28)) {
         ld_0 = iOpen(Symbol(), PERIOD_H1, li_28);
         DrawOpenLine("LonOpen" + ls_8, "London Open", ls_8, ld_0);
         gi_136 = iTime(Symbol(), PERIOD_H1, li_28);
      }
      if (li_20 == London_Close && gi_136 != iTime(Symbol(), PERIOD_H1, li_28)) {
         ld_0 = iOpen(Symbol(), PERIOD_H1, li_28);
         DrawOpenLine("LoCOpen" + ls_8, "London Close", ls_8, ld_0);
         gi_136 = iTime(Symbol(), PERIOD_H1, li_28);
      }
      if (li_20 == NY_Open && gi_136 != iTime(Symbol(), PERIOD_H1, li_28)) {
         ld_0 = iOpen(Symbol(), PERIOD_H1, li_28);
         DrawOpenLine("NY_Open" + ls_8, "NY Open", ls_8, ld_0);
         gi_136 = iTime(Symbol(), PERIOD_H1, li_28);
      }
   }
   return (0);
}

void DrawOpenLine(string as_0, string as_8, string as_16, double ad_24) {
   int li_32 = StrToTime(as_16);
   color li_36 = White;
   if (StringSubstr(as_0, 0, 2) == "Sy") li_36 = SydneyColor;
   if (StringSubstr(as_0, 0, 2) == "To") li_36 = TokyoColor;
   if (StringSubstr(as_0, 0, 2) == "Fr") li_36 = FrankColor;
   if (StringSubstr(as_0, 0, 2) == "Lo") li_36 = LondonColor;
   if (StringSubstr(as_0, 0, 2) == "NY") li_36 = NYColor;
   ObjectCreate(as_0, OBJ_VLINE, 0, li_32, ad_24);
   ObjectSet(as_0, OBJPROP_BACK, TRUE);
   ObjectSet(as_0, OBJPROP_COLOR, li_36);
   ObjectSet(as_0, OBJPROP_STYLE, STYLE_DOT);
   if(ShowTexts)
   {
   ObjectCreate(as_0 + "_Label", OBJ_TEXT, 0, li_32, ad_24);
   ObjectSetText(as_0 + "_Label", as_8, LabelFontSize);
   ObjectSet(as_0 + "_Label", OBJPROP_ANGLE, 90);
   ObjectSet(as_0 + "_Label", OBJPROP_COLOR, li_36);
   }
}