#property copyright "Copyright Š 2008, FOREXflash Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 DeepSkyBlue
#property indicator_color3 Yellow
#property indicator_color4 Lime
#property indicator_color5 White
#property indicator_color6 Fuchsia
#property indicator_color7 Gray
#property indicator_color8 DarkOrange

extern int NumberOfBars = 500;
extern int MAPeriod = 100;
extern int LookBack = 20;
extern bool ShowText = TRUE;
extern int Corner = 1;
extern bool ShowOCLines = TRUE;
extern int OCPeriod = 14;
extern bool ShowBarTime = TRUE;
extern color Trending = C'0x23,0x23,0x23';
extern color Ranging = Black;
string g_fontname_116 = "Trebuchet MS";
int g_fontsize_124 = 13;
int g_color_128 = White;
int g_x_132 = 15;
int g_y_136 = 35;
bool gi_140 = TRUE;
int g_color_144 = Black;
int g_fontsize_148 = 20;
string g_fontname_152 = "Arial Black";
int gi_unused_160 = 1;
int g_str_len_164;
string gs_168 = ":...:...:...:...:";
double gd_176;
double gd_184;
double g_ibuf_192[];
double g_ibuf_196[];
double g_ibuf_200[];
double g_ibuf_204[];
double g_ibuf_208[];
double g_ibuf_212[];
double g_ibuf_216[];
double g_ibuf_220[];
double g_bid_224;
bool gi_232 = TRUE;
int g_timeframe_236 = 0;
int g_shift_240 = -1;

int init() {
  
   SetIndexBuffer(0, g_ibuf_192);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexLabel(0, "Climax High ");
   SetIndexBuffer(1, g_ibuf_196);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexLabel(1, "Neutral");
   SetIndexBuffer(2, g_ibuf_200);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexLabel(2, "Low ");
   SetIndexBuffer(3, g_ibuf_204);
   SetIndexStyle(3, DRAW_HISTOGRAM);
   SetIndexLabel(3, "HighChurn ");
   SetIndexBuffer(4, g_ibuf_208);
   SetIndexStyle(4, DRAW_HISTOGRAM);
   SetIndexLabel(4, "Climax Low ");
   SetIndexBuffer(5, g_ibuf_212);
   SetIndexStyle(5, DRAW_HISTOGRAM);
   SetIndexLabel(5, "ClimaxChurn ");
   SetIndexBuffer(6, g_ibuf_216);
   SetIndexStyle(6, DRAW_LINE, STYLE_DOT, 1);
   SetIndexLabel(6, "Average(" + MAPeriod + ")");
   SetIndexBuffer(7, g_ibuf_220);
   SetIndexStyle(7, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexLabel(7, "TickSeparateVolume");
   IndicatorShortName("VSAŠ MULTY VOLUME HISTOGRAM");
   if (ShowText == TRUE) draw_objects();
   return (0);
}

int deinit() {
   string l_name_4;
   for (int li_0 = ObjectsTotal() - 1; li_0 >= 0; li_0--) {
      l_name_4 = ObjectName(li_0);
      if (StringSubstr(l_name_4, 0, 8) == "Trend2") ObjectDelete(l_name_4);
   }
   if (ObjectFind("BarTimer1") != -1) ObjectDelete("BarTimer1");
   ObjectDelete("Market_Price_Label1");
   ObjectsDeleteAll(0, OBJ_LABEL);
   return (0);
}

int BarTimer() {
   int li_0 = 0;
   int li_4 = 0;
   double ld_8 = 0.0;
   string l_str_concat_16 = "";
   string ls_24 = "";
   string ls_32 = "";
   ObjectCreate("BarTimer1", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSet("BarTimer1", OBJPROP_CORNER, Corner);
   ObjectSet("BarTimer1", OBJPROP_XDISTANCE, g_x_132);
   ObjectSet("BarTimer1", OBJPROP_YDISTANCE, g_y_136);
   li_4 = TimeCurrent() - Time[0];
   li_0 = (g_str_len_164 - 1) * li_4 / (60 * Period());
   ld_8 = 100.0 * li_4 / (60 * Period());
   if (li_0 > g_str_len_164 - 1) li_0 = g_str_len_164 - 1;
   if (li_0 > 0) ls_32 = StringSubstr(gs_168, 0, li_0);
   if (li_0 < g_str_len_164 - 1) ls_24 = StringSubstr(gs_168, li_0 + 1, g_str_len_164 - li_0 - 1);
   l_str_concat_16 = StringConcatenate(ls_32, "|", ls_24, "  ", DoubleToStr(ld_8, 0), "%");
   ObjectSetText("BarTimer1", l_str_concat_16, g_fontsize_124, g_fontname_116, g_color_128);
   return (0);
}

int MPrice() {
   int li_0;
   if (gi_140 == TRUE) {
      if (Bid > g_bid_224) g_color_144 = LawnGreen;
      if (Bid < g_bid_224) g_color_144 = Red;
      g_bid_224 = Bid;
   }
   string ls_4 = StringSubstr(Symbol(), 3, 3);
   if (ls_4 == "JPY") li_0 = 2;
   else li_0 = 4;
   string l_dbl2str_12 = DoubleToStr(Bid, li_0);
   ObjectCreate("Market_Price_Label1", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("Market_Price_Label1", l_dbl2str_12, g_fontsize_148, g_fontname_152, g_color_144);
   ObjectSet("Market_Price_Label1", OBJPROP_CORNER, Corner);
   ObjectSet("Market_Price_Label1", OBJPROP_XDISTANCE, 15);
   ObjectSet("Market_Price_Label1", OBJPROP_YDISTANCE, 144);
   return (0);
}

int start() {
   double l_volume_16;
   double ld_24;
   double ld_32;
   double ld_40;
   double ld_48;
   double ld_56;
   double ld_64;
   double ld_72;
   double ld_80;
   double ld_88;
   string l_name_112;
   
   TickVolumeDiff();
   if (ShowText == TRUE) {
      draw_objects();
      BarTimer();
      MPrice();
   }
   if (ShowOCLines == TRUE) OpenCloseLines();
   if (ShowBarTime == TRUE) BarTime();
   int l_window_12 = WindowFind("VSAŠ MULTY VOLUME HISTOGRAM");
   int li_100 = IndicatorCounted();
   if (li_100 > 0) li_100--;
   if (NumberOfBars == 0) NumberOfBars = Bars - li_100;
   int li_96 = NumberOfBars;
   for (int li_104 = 0; li_104 < li_96; li_104++) {
      g_ibuf_192[li_104] = 0;
      g_ibuf_196[li_104] = Volume[li_104];
      g_ibuf_200[li_104] = 0;
      g_ibuf_204[li_104] = 0;
      g_ibuf_208[li_104] = 0;
      g_ibuf_212[li_104] = 0;
      ld_32 = 0;
      ld_40 = 0;
      ld_48 = 0;
      ld_56 = 0;
      ld_64 = 99999999;
      ld_72 = 0;
      ld_80 = 0;
      ld_88 = 0;
      l_volume_16 = Volume[iLowest(NULL, 0, MODE_VOLUME, 20, li_104)];
      if (Volume[li_104] == l_volume_16) {
         g_ibuf_200[li_104] = NormalizeDouble(Volume[li_104], 0);
         g_ibuf_196[li_104] = 0;
      }
      ld_24 = High[li_104] - Low[li_104];
      ld_32 = Volume[li_104] * ld_24;
      if (ld_24 != 0.0) ld_40 = Volume[li_104] / ld_24;
      for (int li_108 = li_104; li_108 < li_104 + MAPeriod; li_108++) ld_88 = Volume[li_108] + ld_88;
      g_ibuf_216[li_104] = NormalizeDouble(ld_88 / MAPeriod, 0);
      for (li_108 = li_104; li_108 < li_104 + LookBack; li_108++) {
         ld_72 = Volume[li_108] * (High[li_108] - Low[li_108]);
         if (ld_72 >= ld_48) ld_48 = ld_72;
         if (Volume[li_108] * (High[li_108] - Low[li_108]) != 0.0) {
            ld_80 = Volume[li_108] / (High[li_108] - Low[li_108]);
            if (ld_80 > ld_56) ld_56 = ld_80;
            if (ld_80 < ld_64) ld_64 = ld_80;
         }
      }
      if (ld_32 == ld_48 && Close[li_104] > (High[li_104] + Low[li_104]) / 2.0) {
         g_ibuf_192[li_104] = NormalizeDouble(Volume[li_104], 0);
         g_ibuf_196[li_104] = 0;
         g_ibuf_200[li_104] = 0;
      }
      if (ld_40 == ld_56) {
         g_ibuf_204[li_104] = NormalizeDouble(Volume[li_104], 0);
         g_ibuf_196[li_104] = 0;
         g_ibuf_200[li_104] = 0;
         g_ibuf_192[li_104] = 0;
      }
      if (ld_32 == ld_48 && ld_40 == ld_56) {
         g_ibuf_212[li_104] = NormalizeDouble(Volume[li_104], 0);
         g_ibuf_196[li_104] = 0;
         g_ibuf_192[li_104] = 0;
         g_ibuf_204[li_104] = 0;
         g_ibuf_200[li_104] = 0;
      }
      if (ld_32 == ld_48 && Close[li_104] <= (High[li_104] + Low[li_104]) / 2.0) {
         g_ibuf_208[li_104] = NormalizeDouble(Volume[li_104], 0);
         g_ibuf_212[li_104] = 0;
         g_ibuf_196[li_104] = 0;
         g_ibuf_192[li_104] = 0;
         g_ibuf_204[li_104] = 0;
         g_ibuf_200[li_104] = 0;
      }
   }
   int l_count_120 = 0;
   for (li_104 = li_96 - 1; li_104 > 0; li_104--) {
      if (Volume[li_104] > g_ibuf_216[li_104]) {
         l_count_120++;
         l_name_112 = "Trend2" + l_count_120;
         if (ObjectFind(l_name_112) == -1) ObjectCreate(l_name_112, OBJ_RECTANGLE, l_window_12, 0, 0);
         ObjectSet(l_name_112, OBJPROP_COLOR, Ranging);
         ObjectSet(l_name_112, OBJPROP_PRICE1, 100000000);
         ObjectSet(l_name_112, OBJPROP_PRICE2, -100000000);
         ObjectSet(l_name_112, OBJPROP_TIME1, Time[li_104]);
         ObjectSet(l_name_112, OBJPROP_TIME2, Time[li_104 - 1]);
      } else {
         if (Volume[li_104] < g_ibuf_216[li_104]) {
            l_count_120++;
            l_name_112 = "Trend2" + l_count_120;
            if (ObjectFind(l_name_112) == -1) ObjectCreate(l_name_112, OBJ_RECTANGLE, l_window_12, 0, 0);
            ObjectSet(l_name_112, OBJPROP_COLOR, Trending);
            ObjectSet(l_name_112, OBJPROP_PRICE1, 100000000);
            ObjectSet(l_name_112, OBJPROP_PRICE2, -100000000);
            ObjectSet(l_name_112, OBJPROP_TIME1, Time[li_104]);
            ObjectSet(l_name_112, OBJPROP_TIME2, Time[li_104 - 1]);
         } else ObjectSet(l_name_112, OBJPROP_TIME2, Time[li_104 - 1]);
      }
   }
   return (0);
}

void TickVolumeDiff() {
   int l_shift_4;
   for (int li_0 = 0; li_0 < iBars(Symbol(), PERIOD_M1); li_0++) {
      l_shift_4 = iBarShift(Symbol(), Period(), iTime(Symbol(), PERIOD_M1, li_0), TRUE);
      if (g_shift_240 != l_shift_4) {
         gd_176 = 0;
         gd_184 = 0;
         g_ibuf_220[l_shift_4] = 0;
      }
      if (l_shift_4 != -1) {
         if (iClose(Symbol(), PERIOD_M1, li_0) > iClose(Symbol(), PERIOD_M1, li_0 + 1)) gd_176 += iVolume(Symbol(), PERIOD_M1, li_0);
         if (iClose(Symbol(), PERIOD_M1, li_0) < iClose(Symbol(), PERIOD_M1, li_0 + 1)) gd_184 -= iVolume(Symbol(), PERIOD_M1, li_0);
         if (iClose(Symbol(), PERIOD_M1, li_0) == iClose(Symbol(), PERIOD_M1, li_0 + 1)) {
            gd_176 += iVolume(Symbol(), PERIOD_M1, li_0) / 2.0;
            gd_184 -= iVolume(Symbol(), PERIOD_M1, li_0) / 2.0;
         }
      }
      g_ibuf_220[l_shift_4] = (gd_176 + gd_184) / 2.0;
      g_shift_240 = l_shift_4;
   }
}

void draw_objects() {
   ObjectCreate("VBox", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("VBox", "V  S  A  Ž", 14, "Trebuchet MS", Orange);
   ObjectSet("VBox", OBJPROP_CORNER, Corner);
   ObjectSet("VBox", OBJPROP_XDISTANCE, 15);
   ObjectSet("VBox", OBJPROP_YDISTANCE, 1);
   ObjectCreate("VBox1", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("VBox1", "Better/Tick Separate Volume", 8, "Trebuchet MS", Gray);
   ObjectSet("VBox1", OBJPROP_CORNER, Corner);
   ObjectSet("VBox1", OBJPROP_XDISTANCE, 15);
   ObjectSet("VBox1", OBJPROP_YDISTANCE, 18);
   string l_dbl2str_0 = DoubleToStr(g_ibuf_220[0], 1);
   ObjectCreate("TSV", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("TSV", "TICK SEPARATE VOLUME: " + l_dbl2str_0 + "", 13, "Trebuchet MS", White);
   ObjectSet("TSV", OBJPROP_CORNER, Corner);
   ObjectSet("TSV", OBJPROP_XDISTANCE, 15);
   ObjectSet("TSV", OBJPROP_YDISTANCE, 58);
   if (g_ibuf_220[0] >= 1.0) ObjectSetText("TSV", "TICK VOLUME: " + l_dbl2str_0 + "", 13, "Trebuchet MS", Lime);
   if (g_ibuf_220[0] <= 1.0) ObjectSetText("TSV", "TICK VOLUME: " + l_dbl2str_0 + "", 13, "Trebuchet MS", Red);
   ObjectCreate("TSV2", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("TSV2", "TICK VOLUME IS BELOW AVERAGE.", 8, "Trebuchet MS", White);
   ObjectSet("TSV2", OBJPROP_CORNER, Corner);
   ObjectSet("TSV2", OBJPROP_XDISTANCE, 15);
   ObjectSet("TSV2", OBJPROP_YDISTANCE, 76);
   if (g_ibuf_220[0] > g_ibuf_220[1] && g_ibuf_220[0] > g_ibuf_220[2] && g_ibuf_220[0] > g_ibuf_220[3] && g_ibuf_220[0] > g_ibuf_220[4] && g_ibuf_220[0] > g_ibuf_220[5] &&
      g_ibuf_220[0] > g_ibuf_220[6] && g_ibuf_220[0] > g_ibuf_220[7] && g_ibuf_220[0] > g_ibuf_220[8] && g_ibuf_220[0] > g_ibuf_220[9] && g_ibuf_220[0] > g_ibuf_220[10]) ObjectSetText("TSV2", "TICK VOLUME IS ABOVE AVERAGE!!!", 8, "Trebuchet MS", Orange);
   string l_dbl2str_8 = DoubleToStr(g_ibuf_216[0], 1);
   ObjectCreate("v4MA", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("v4MA", "AVERAGE VOLUME:" + l_dbl2str_8, 13, "Trebuchet MS", Lime);
   ObjectSet("v4MA", OBJPROP_CORNER, Corner);
   ObjectSet("v4MA", OBJPROP_XDISTANCE, 15);
   ObjectSet("v4MA", OBJPROP_YDISTANCE, 92);
   ObjectCreate("BA_v4MA", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("BA_v4MA", "VOLUME IS BELOW AVERAGE.", 8, "Trebuchet MS", White);
   ObjectSet("BA_v4MA", OBJPROP_CORNER, Corner);
   ObjectSet("BA_v4MA", OBJPROP_XDISTANCE, 15);
   ObjectSet("BA_v4MA", OBJPROP_YDISTANCE, 110);
   if (g_ibuf_216[0] > g_ibuf_216[1] && g_ibuf_216[0] > g_ibuf_216[2] && g_ibuf_216[0] > g_ibuf_216[3] && g_ibuf_216[0] > g_ibuf_216[4] && g_ibuf_216[0] > g_ibuf_216[5] &&
      g_ibuf_216[0] > g_ibuf_216[6] && g_ibuf_216[0] > g_ibuf_216[7] && g_ibuf_216[0] > g_ibuf_216[8] && g_ibuf_216[0] > g_ibuf_216[9] && g_ibuf_216[0] > g_ibuf_216[10] &&
      g_ibuf_216[0] > g_ibuf_216[11] && g_ibuf_216[0] > g_ibuf_216[12] && g_ibuf_216[0] > g_ibuf_216[13] && g_ibuf_216[0] > g_ibuf_216[14] && g_ibuf_216[0] > g_ibuf_216[15] &&
      g_ibuf_216[0] > g_ibuf_216[16] && g_ibuf_216[0] > g_ibuf_216[17] && g_ibuf_216[0] > g_ibuf_216[18] && g_ibuf_216[0] > g_ibuf_216[19] && g_ibuf_216[0] > g_ibuf_216[20]) ObjectSetText("BA_v4MA", "VOLUME IS ABOVE AVERAGE!!!", 8, "Trebuchet MS", Red);
   ObjectCreate("BetterVol", OBJ_LABEL, WindowFind("VSAŠ MULTY VOLUME HISTOGRAM"), 0, 0);
   ObjectSetText("BetterVol", "PENDING BAR SIGNAL...", 13, "Trebuchet MS", Gray);
   ObjectSet("BetterVol", OBJPROP_CORNER, Corner);
   ObjectSet("BetterVol", OBJPROP_XDISTANCE, 15);
   ObjectSet("BetterVol", OBJPROP_YDISTANCE, 127);
   if (g_ibuf_208[1] > 1.0) ObjectSetText("BetterVol", "*Start/End of down trend_Pullback during up trend*", 10, "Trebuchet MS", White);
   if (g_ibuf_192[1] > 1.0) ObjectSetText("BetterVol", "*Start/End of up trend_Pullback during down trend*", 10, "Trebuchet MS", Red);
   if (g_ibuf_204[1] > 1.0) ObjectSetText("BetterVol", "*End of up/down trend_Profit taking mid-trend*", 10, "Trebuchet MS", Lime);
   if (g_ibuf_212[1] > 1.0) ObjectSetText("BetterVol", "*Seen on tops and bottoms_Reversal or continuation*", 10, "Trebuchet MS", Fuchsia);
   if (g_ibuf_200[1] > 1.0) ObjectSetText("BetterVol", "*End of up/down trend_Pullback mid-trend*", 10, "Trebuchet MS", Yellow);
   if (g_ibuf_196[1] > 1.0) ObjectSetText("BetterVol", "*No signal_Neutral*", 10, "Trebuchet MS", DeepSkyBlue);
}

int OpenCloseLines() {
   double l_iclose_0 = iClose(NULL, PERIOD_D1, iHighest(NULL, PERIOD_D1, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_8 = iClose(NULL, PERIOD_H4, iHighest(NULL, PERIOD_H4, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_16 = iClose(NULL, PERIOD_H1, iHighest(NULL, PERIOD_H1, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_24 = iClose(NULL, PERIOD_M30, iHighest(NULL, PERIOD_M30, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_32 = iClose(NULL, PERIOD_M15, iHighest(NULL, PERIOD_M15, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_40 = iClose(NULL, PERIOD_D1, iLowest(NULL, PERIOD_D1, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_48 = iClose(NULL, PERIOD_H4, iLowest(NULL, PERIOD_H4, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_56 = iClose(NULL, PERIOD_H1, iLowest(NULL, PERIOD_H1, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_64 = iClose(NULL, PERIOD_M30, iLowest(NULL, PERIOD_M30, MODE_CLOSE, OCPeriod, 1));
   double l_iclose_72 = iClose(NULL, PERIOD_M15, iLowest(NULL, PERIOD_M15, MODE_CLOSE, OCPeriod, 1));
   drawLine("HH_D1", Time[36], Time[30], l_iclose_0, l_iclose_0, 3, FALSE, Lime, 1);
   drawLine("HH_H4", Time[30], Time[24], l_iclose_8, l_iclose_8, 3, FALSE, Lime, 1);
   drawLine("HH_H1", Time[18], Time[12], l_iclose_16, l_iclose_16, 3, FALSE, Lime, 2);
   drawLine("HH_M30", Time[12], Time[6], l_iclose_24, l_iclose_24, 3, FALSE, Lime, 2);
   drawLine("HH_M15", Time[6], Time[0], l_iclose_32, l_iclose_32, 3, FALSE, Lime, 1);
   drawLine("LL_D1", Time[36], Time[30], l_iclose_40, l_iclose_40, 3, FALSE, Red, 1);
   drawLine("LL_H4", Time[30], Time[24], l_iclose_48, l_iclose_48, 3, FALSE, Red, 1);
   drawLine("LL_H1", Time[18], Time[12], l_iclose_56, l_iclose_56, 3, FALSE, Red, 2);
   drawLine("LL_M30", Time[12], Time[6], l_iclose_64, l_iclose_64, 3, FALSE, Red, 2);
   drawLine("LL_M15", Time[6], Time[0], l_iclose_72, l_iclose_72, 3, FALSE, Red, 1);
   drawTXTLabel("D1 Bar HC", l_iclose_0, Time[33], White);
   drawTXTLabel("H4 Bar HC", l_iclose_8, Time[27], White);
   drawTXTLabel("H1 Bar HC", l_iclose_16, Time[15], White);
   drawTXTLabel("M30 Bar HC", l_iclose_24, Time[9], White);
   drawTXTLabel("M15 Bar HC", l_iclose_32, Time[3], White);
   drawTXTLabel("D1 Bar LC", l_iclose_40, Time[33], White);
   drawTXTLabel("H4 Bar LC", l_iclose_48, Time[27], White);
   drawTXTLabel("H1 Bar LC", l_iclose_56, Time[15], White);
   drawTXTLabel("M30 Bar LC", l_iclose_64, Time[9], White);
   drawTXTLabel("M15 Bar LC", l_iclose_72, Time[3], White);
   return (0);
}

void drawTXTLabel(string a_name_0, double a_price_8, int a_datetime_16, color a_color_20) {
   if (ObjectFind(a_name_0) != 0) {
      ObjectCreate(a_name_0, OBJ_TEXT, 0, a_datetime_16, a_price_8);
      ObjectSetText(a_name_0, a_name_0, 8, "Tahoma", CLR_NONE);
      ObjectSet(a_name_0, OBJPROP_COLOR, a_color_20);
      return;
   }
   ObjectMove(a_name_0, 0, a_datetime_16, a_price_8);
}

void drawLine(string a_name_0, int a_datetime_8, int a_datetime_12, double a_price_16, double a_price_24, int ai_unused_32, int a_bool_36, color a_color_40, int ai_44) {
   if (ObjectFind(a_name_0) != 0) {
      ObjectCreate(a_name_0, OBJ_TREND, 0, a_datetime_8, a_price_16, a_datetime_12, a_price_24);
      if (ai_44 == 1) ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
      else {
         if (ai_44 == 2) ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_DASHDOT);
         else ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_DOT);
      }
      ObjectSet(a_name_0, OBJPROP_COLOR, a_color_40);
      ObjectSet(a_name_0, OBJPROP_WIDTH, 2);
      ObjectSet(a_name_0, OBJPROP_RAY, a_bool_36);
      return;
   }
   ObjectDelete(a_name_0);
   ObjectCreate(a_name_0, OBJ_TREND, 0, a_datetime_8, a_price_16, a_datetime_12, a_price_24);
   if (ai_44 == 1) ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
   else {
      if (ai_44 == 2) ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_DASHDOT);
      else ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_DOT);
   }
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_40);
   ObjectSet(a_name_0, OBJPROP_WIDTH, 2);
   ObjectSet(a_name_0, OBJPROP_RAY, a_bool_36);
}

void BarTime() {
   if (g_timeframe_236 == 0) g_timeframe_236 = Period();
   int li_64 = iTime(NULL, g_timeframe_236, 0) + 60 * g_timeframe_236 - TimeCurrent();
   int li_80 = iTime(NULL, PERIOD_D1, 0) + 86400 - TimeCurrent();
   int li_84 = iTime(NULL, PERIOD_H4, 0) + 14400 - TimeCurrent();
   int li_88 = iTime(NULL, PERIOD_H1, 0) + 3600 - TimeCurrent();
   int li_92 = iTime(NULL, PERIOD_M30, 0) + 1800 - TimeCurrent();
   int li_96 = iTime(NULL, PERIOD_M15, 0) + 900 - TimeCurrent();
   int li_100 = iTime(NULL, PERIOD_M5, 0) + 300 - TimeCurrent();
   int li_104 = iTime(NULL, PERIOD_M1, 0) + 60 - TimeCurrent();
   double ld_0 = li_64 / 60.0;
   double ld_8 = li_80 / 60.0;
   double ld_16 = li_84 / 60.0;
   double ld_24 = li_88 / 60.0;
   double ld_32 = li_92 / 60.0;
   double ld_40 = li_96 / 60.0;
   double ld_48 = li_100 / 60.0;
   double ld_56 = li_104 / 60.0;
   int li_68 = li_64 % 60;
   int li_108 = li_64 % 60;
   int li_112 = li_80 % 60;
   int li_116 = li_84 % 60;
   int li_120 = li_88 % 60;
   int li_124 = li_92 % 60;
   int li_128 = li_96 % 60;
   int li_132 = li_100 % 60;
   int li_136 = li_104 % 60;
   li_64 = (li_64 - li_64 % 60) / 60;
   int li_76 = (li_64 - li_64 % 60) / 60;
   li_80 = (li_80 - li_80 % 60) / 60;
   li_84 = (li_84 - li_84 % 60) / 60;
   li_88 = (li_88 - li_88 % 60) / 60;
   li_92 = (li_92 - li_92 % 60) / 60;
   li_96 = (li_96 - li_96 % 60) / 60;
   li_100 = (li_100 - li_100 % 60) / 60;
   li_104 = (li_104 - li_104 % 60) / 60;
   int li_140 = li_64 / 60;
   int li_144 = li_80 / 60;
   int li_148 = li_84 / 60;
   int li_152 = li_88 / 60;
   int li_156 = li_92 / 60;
   int li_160 = li_96 / 60;
   int li_164 = li_100 / 60;
   int li_168 = li_104 / 60;
   string ls_172 = "                   <" + li_64 + ":" + li_68;
   string ls_180 = "[M1] " + li_104 + "m :" + li_136;
   string ls_188 = "[M5] " + li_100 + "m :" + li_132;
   string ls_196 = "[M15] " + li_96 + "m :" + li_128;
   string ls_204 = "[M30] " + li_92 + "m :" + li_124;
   string ls_212 = "[M60] " + li_88 + "m :" + li_120;
   string ls_220 = "[H4] " + li_84 + "m :" + li_116;
   string ls_228 = "[D1] " + li_80 + "m :" + li_112;
   ObjectDelete("time");
   if (ObjectFind("time") != 0) {
      if (gi_232) {
         ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0] + 0.0);
         ObjectsRedraw();
      }
      if (gi_232) {
         ObjectSetText("time", StringSubstr(ls_172, 0), 9, "Tahoma", White);
         ObjectsRedraw();
      }
   } else ObjectMove("time", 0, Time[0], Close[0] + 0.0005);
}