//+------------------------------------------------------------------+ //| Time_Table | //| Copyright 2016, Frostow | //+------------------------------------------------------------------+ #property indicator_chart_window input color Color=clrBlack;//text color input int spread_x = -1; // x of spread lable input int spread_y = -1; // y of spread lable input int time_x = -1; // x of time lable input int time_y = -1; // y of time lable //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { int height= ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0); int width = ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0); int x_spread = 0; int y_spread = 0; int x_time = 0; int y_time = 0; if(spread_x>0 && spread_x0 && spread_y0 && time_x0 && time_y=0) { // seconds if(dif<60) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+dif+"s"); } // minutes and seconds if(dif>60 && dif<3600) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+ MathFloor(dif/60)+"m "+(dif-60*MathFloor(dif/60))+"s"); } // hours and minutes and seconds if(dif>3600 && dif<=86400) { int h = MathFloor(dif / 3600); int m = MathFloor(dif / 60) - 60 * h; int s = dif - h * 3600 - 60 * m; if(h>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+h+"H "+m+"m "+s+"s"); } else { if(m>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+m+"m "+s+"s"); } else { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+s+"s"); } } } // days, hours and minutes if(dif>86400 && dif<=604800) { int d=MathFloor(dif/86400); h = MathFloor(dif / 3600) - 24 * d; m = MathFloor(dif / 60) - 1440 * d - 60 * h; s = dif - d * 86400 - h * 3600 - 60 * m; if(d>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+d+"D "+h+"H "+m+"m "); } else { if(h>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+h+"H "+m+"m "+s+"s"); } else { if(m>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+m+"m "+s+"s"); } else { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+s+"s"); } } } } // weeks, days and hours if(dif>604800) { int w=MathFloor(dif/604800); d = MathFloor(dif / 86400) - 7 * w; h = MathFloor(dif / 3600) - 24 * d - 168 * w; m = MathFloor(dif / 60) - 1440 * d - 60 * h - 10080 * w; s = dif - d * 86400 - h * 3600 - 60 * m - 604800 * w; if(w>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+w+"W "+d+"D "+h+"H "); } else { if(d>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+d+"D "+h+"H "+m+"m "); } else { if(h>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+h+"H "+m+"m "+s+"s"); } else { if(m>0) { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+m+"m "+s+"s"); } else { ObjectSetString(0,"time_table",OBJPROP_TEXT,"NEXT BAR IN: "+s+"s"); } } } } } } } //+------------------------------------------------------------------+ //| Delete all used objects | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { // deleting objects ObjectDelete(0,"time_table"); ObjectDelete(0,"spread"); EventKillTimer(); } //+------------------------------------------------------------------+ //| OnChartEvent function. Finding out if the chart was changed | //+------------------------------------------------------------------+ void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam) { // if the chart's size was changed ==> change the position of labels if(id==CHARTEVENT_CHART_CHANGE) { int height= ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0); int width = ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0); int x_spread = 0; int y_spread = 0; int x_time = 0; int y_time = 0; if(spread_x>0 && spread_x0 && spread_y0 && time_x0 && time_y