/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2010, forexwhiz.appspot.com"
#property link      "http://forexwhiz.appspot.com"

#property indicator_chart_window

extern int NrOfDays = 5;
extern string Info1 = "<< Extra Vertical line 1  >>";
extern bool VLine1Show = TRUE;
extern int VLine1Hour = 3;
extern bool VLine1OnHour = FALSE;
extern color VLine1Color = Lime;
extern int VLine1Style = 2;
extern int VLine1Width = 1;
extern string VLine1label = "London Open";
extern string Info2 = "<< Extra Vertical line 2  >>";
extern bool VLine2Show = TRUE;
extern int VLine2Hour = 19;
extern bool VLine2OnHour = FALSE;
extern color VLine2Color = Gold;
extern int VLine2Style = 2;
extern int VLine2Width = 1;
extern string VLine2label = "London Close";
extern string Info3 = "<< Extra Vertical line 3  >>";
extern bool VLine3Show = FALSE;
extern int VLine3Hour = 11;
extern bool VLine3OnHour = TRUE;
extern color VLine3Color = Gold;
extern int VLine3Style = 2;
extern int VLine3Width = 1;
extern string VLine3label = "VLine 3";
extern string Info4 = "<< Extra Vertical line 4  >>";
extern bool VLine4Show = FALSE;
extern int VLine4Hour = 12;
extern bool VLine4OnHour = TRUE;
extern color VLine4Color = Gold;
extern int VLine4Style = 2;
extern int VLine4Width = 1;
extern string VLine4label = "VLine 4";
string gs_240;
string gs_248 = "v1.00";
bool gi_256;

int init() {
   gs_240 = "Xi-VLines " + gs_248;
   IndicatorShortName(gs_240);
   gi_256 = FALSE;
   return (0);
}

int deinit() {
   for (int li_0 = ObjectsTotal() - 1; li_0 > -1; li_0--)
      if (StringFind(ObjectName(li_0), "Xi-VLines") >= 0) ObjectDelete(ObjectName(li_0));
   return (0);
}

int start() {
   int l_ind_counted_4 = IndicatorCounted();
   if (l_ind_counted_4 < 0) return (-1);
   int li_0 = Bars - l_ind_counted_4;
   if (gi_256 == FALSE) {
      if (VLine1Show == TRUE) DrawPreviousVLine1();
      if (VLine2Show == TRUE) DrawPreviousVLine2();
      if (VLine3Show == TRUE) DrawPreviousVLine3();
      if (VLine4Show == TRUE) DrawPreviousVLine4();
      gi_256 = TRUE;
   }
   DrawCurrentVLines(li_0);
   return (0);
}

int DrawCurrentVLines(int ai_0) {
   int li_4;
   for (int l_index_8 = 0; l_index_8 <= ai_0; l_index_8++) {
      if (VLine1Show == TRUE && TimeHour(Time[l_index_8]) == VLine1Hour && TimeMinute(Time[l_index_8]) == 0) {
         if (VLine1OnHour == TRUE) li_4 = 0;
         else li_4 = 1;
         DrawLine(Time[l_index_8 + li_4], VLine1Style, VLine1Width, VLine1Color, "VLine1");
         if (StringLen(VLine1label) > 0) DrawTextLabel(Time[l_index_8 + li_4], VLine1label, VLine1Color);
      }
   }
   return (0);
}

int DrawPreviousVLine1() {
   int li_0;
   int l_index_4 = 0;
   int l_count_8 = 0;
   while (l_index_4 < Bars && l_count_8 < NrOfDays) {
      if (TimeHour(Time[l_index_4]) == VLine1Hour && TimeMinute(Time[l_index_4]) == 0) {
         if (VLine1OnHour == TRUE) li_0 = 0;
         else li_0 = 1;
         DrawLine(Time[l_index_4 + li_0], VLine1Style, VLine1Width, VLine1Color, "VLine1");
         if (StringLen(VLine1label) > 0) DrawTextLabel(Time[l_index_4 + li_0], VLine1label, VLine1Color);
         l_count_8++;
      }
      l_index_4++;
   }
   return (0);
}

int DrawPreviousVLine2() {
   int li_0;
   int l_index_4 = 0;
   int l_count_8 = 0;
   while (l_index_4 < Bars && l_count_8 < NrOfDays) {
      if (TimeHour(Time[l_index_4]) == VLine2Hour && TimeMinute(Time[l_index_4]) == 0) {
         if (VLine2OnHour == TRUE) li_0 = 0;
         else li_0 = 1;
         DrawLine(Time[l_index_4 + li_0], VLine2Style, VLine2Width, VLine2Color, "VLine2");
         if (StringLen(VLine2label) > 0) DrawTextLabel(Time[l_index_4 + li_0], VLine2label, VLine2Color);
         l_count_8++;
      }
      l_index_4++;
   }
   return (0);
}

int DrawPreviousVLine3() {
   int li_0;
   int l_index_4 = 0;
   int l_count_8 = 0;
   while (l_index_4 < Bars && l_count_8 < NrOfDays) {
      if (TimeHour(Time[l_index_4]) == VLine3Hour && TimeMinute(Time[l_index_4]) == 0) {
         if (VLine3OnHour == TRUE) li_0 = 0;
         else li_0 = 1;
         DrawLine(Time[l_index_4 + li_0], VLine3Style, VLine3Width, VLine3Color, "VLine3");
         if (StringLen(VLine3label) > 0) DrawTextLabel(Time[l_index_4 + li_0], VLine3label, VLine3Color);
         l_count_8++;
      }
      l_index_4++;
   }
   return (0);
}

int DrawPreviousVLine4() {
   int li_0;
   int l_index_4 = 0;
   int l_count_8 = 0;
   while (l_index_4 < Bars && l_count_8 < NrOfDays) {
      if (TimeHour(Time[l_index_4]) == VLine4Hour && TimeMinute(Time[l_index_4]) == 0) {
         if (VLine4OnHour == TRUE) li_0 = 0;
         else li_0 = 1;
         DrawLine(Time[l_index_4 + li_0], VLine1Style, VLine4Width, VLine4Color, "VLine4");
         if (StringLen(VLine4label) > 0) DrawTextLabel(Time[l_index_4 + li_0], VLine4label, VLine4Color);
         l_count_8++;
      }
      l_index_4++;
   }
   return (0);
}

int DrawLine(double ad_0, int a_style_8, int a_width_12, color a_color_16, string as_20) {
   string l_name_28 = "Xi-VLines" + as_20 + "_" + TimeToStr(ad_0, TIME_DATE);
   if (ObjectFind(l_name_28) >= 0) ObjectDelete(l_name_28);
   ObjectCreate(l_name_28, OBJ_TREND, 0, ad_0, 0, ad_0, 10);
   ObjectSet(l_name_28, OBJPROP_STYLE, a_style_8);
   ObjectSet(l_name_28, OBJPROP_WIDTH, a_width_12);
   ObjectSet(l_name_28, OBJPROP_BACK, TRUE);
   ObjectSet(l_name_28, OBJPROP_COLOR, a_color_16);
   return (0);
}

int DrawTextLabel(double ad_0, string a_text_8, color a_color_16) {
   double l_price_20 = 0;
   string ls_unused_28 = "";
   string l_name_36 = "Xi-VLines" + a_text_8 + "_" + TimeToStr(ad_0, TIME_DATE);
   l_price_20 = WindowPriceMin() + (WindowPriceMax() - WindowPriceMin()) / 2.0;
   if (ObjectFind(l_name_36) >= 0) ObjectDelete(l_name_36);
   ObjectCreate(l_name_36, OBJ_TEXT, 0, ad_0, l_price_20);
   ObjectSet(l_name_36, OBJPROP_ANGLE, 90);
   ObjectSet(l_name_36, OBJPROP_BACK, TRUE);
   ObjectSetText(l_name_36, a_text_8, 8, "Arial", a_color_16);
   return (0);
}
