# closing_time_frame_labels_0c
# https://usethinkscript.com/threads/labels-to-tell-what-time-frame-is-closing-at-a-certain-time.11870/
#I want for every minute that passes from 9:30 to 16:00, for the label to highlight what time frame closes at that time.
#Using these time frames -> 1,2,3,5,10,15,30,60,240
input show_just_valid_times = no;
def sh = !show_just_valid_times;
def start_time = 0900;
def xsec = SecondsFromTime(start_time);
def xmin = xsec / 60;
input t01 = 1;
input t02 = 2;
input t03 = 3;
input t05 = 5;
input t10 = 10;
input t15 = 15;
input t30 = 30;
input t60 = 60;
input t240 = 240;
def v01 = (xmin % t01 == 0);
def v02 = (xmin % t02 == 0);
def v03 = (xmin % t03 == 0);
def v05 = (xmin % t05 == 0);
def v10 = (xmin % t10 == 0);
def v15 = (xmin % t15 == 0);
def v30 = (xmin % t30 == 0);
def v60 = (xmin % t60 == 0);
def v240 = (xmin % t240 == 0);
addlabel(1, " ", color.black);
addlabel(sh or v01, "1", (if v01 then color.yellow else color.gray));
addlabel(sh or v02, "2", (if v02 then color.yellow else color.gray));
addlabel(sh or v03, "3", (if v03 then color.yellow else color.gray));
addlabel(sh or v05, "5", (if v05 then color.yellow else color.gray));
addlabel(sh or v10, "10", (if v10 then color.yellow else color.gray));
addlabel(sh or v15, "15", (if v15 then color.yellow else color.gray));
addlabel(sh or v30, "30", (if v30 then color.yellow else color.gray));
addlabel(sh or v60, "60", (if v60 then color.yellow else color.gray));
addlabel(sh or v240, "240", (if v240 then color.yellow else color.gray));
#--------------------------------------
input test1 = no;
addlabel(test1, " ", color.black);
addlabel(test1, xmin, color.cyan);
addlabel(test1, t01 + " " + v01, (if v01 then color.yellow else color.gray));
addlabel(test1, t02 + " " + v02, (if v02 then color.yellow else color.gray));
addlabel(test1, t03 + " " + v03, (if v03 then color.yellow else color.gray));
addlabel(test1, t05 + " " + v05, (if v05 then color.yellow else color.gray));
addlabel(test1, t10 + " " + v10, (if v10 then color.yellow else color.gray));
addlabel(test1, t15 + " " + v15, (if v15 then color.yellow else color.gray));
addlabel(test1, t30 + " " + v30, (if v30 then color.yellow else color.gray));
addlabel(test1, t60 + " " + v60, (if v60 then color.yellow else color.gray));
addlabel(test1, t240 + " " + v240, (if v240 then color.yellow else color.gray));
def r01 = (xmin % t01);
def r02 = (xmin % t02);
def r03 = (xmin % t03);
def r05 = (xmin % t05);
def r10 = (xmin % t10);
def r15 = (xmin % t15);
def r30 = (xmin % t30);
def r60 = (xmin % t60);
def r240 = (xmin % t240);
input test2 = no;
addchartbubble(test2, low,
xmin + "\n" +
r01 + "\n" +
r02 + "\n" +
r03 + "\n" +
r05 + "\n" +
r10 + "\n" +
r15 + "\n" +
r30 + "\n" +
r60 + "\n" +
r240
, color.yellow, no);
#