#bar_timer_labels2
# add progress bar
#https://usethinkscript.com/threads/need-signal-appear-between-the-0-5th-minute-of-the-hour.16906/#post-133370
#SleepyZ
declare lower;
input aggregation = 5;#hint aggregation: Does not work first bar for aggregation = 4, 20 and 60
input showverticalline = no;
def begin = if aggregation == 60 then 1000 else if aggregation == 4 then 0932 else if aggregation == 20 then 0940 else 0930;
input end = 1600;
def bar = if SecondsTillTime(begin) == 0 and
SecondsFromTime(begin) == 0
then 0
else bar[1] + 1;
AddVerticalLine(if showverticalline and GetDay() == GetLastDay() and SecondsFromTime(begin) >= 0
then bar % ((Ceil(aggregation)) / (GetAggregationPeriod() / 60000)) == 0
else Double.NaN,
color = Color.BLUE, stroke = Curve.FIRM);
def start = if GetDay() == GetLastDay() and SecondsFromTime(begin) >= 0
then aggregation - bar % ((Ceil(aggregation) / (GetAggregationPeriod() / 60000)))
else start[1];
def elapsed_min = (bar % ((Ceil(aggregation) / (GetAggregationPeriod() / 60000))));
input showlabel = yes;
AddLabel(showlabel, "Chart Aggregation : " + aggregation, Color.CYAN);
#AddLabel(showlabel, "Current Minute: " + (bar % ((Ceil(aggregation) / (GetAggregationPeriod() / 60000)))) + " ", Color.WHITE);
AddLabel(showlabel, "Current Minute: " + elapsed_min + " ", Color.WHITE);
AddLabel(showlabel, " Minutes Remaining : " + start, if start > 1 then Color.YELLOW else color.red);
input bubblemover = -1;
def x = bubblemover;
def x1 = x + 1;
plot line0 = 0;
plot line1 = 1;
line1.SetDefaultColor(Color.BLACK);
line0.SetDefaultColor(Color.BLACK);
AddChartBubble(!IsNaN(close[x1]) and IsNaN(close[x]), line0, start[x1] , if start[x1] > 1 then Color.yellow else Color.RED );
#------------------------------
# horz_progress_bar_02
# progress bar (labels)
# place this code at the end of a study and calculate a percent number for the data to display
#------------------------
# 23-10 chg to- 2 colors
# halcyonguy
# 22-04-04
# build a horizontal progress bar, 1 to 100
#------------------------
# enter a % number to display in a progress bar
#input percent = 38;
def percent = round(100*(elapsed_min/aggregation),0);
#------------------------
def p = percent;
def q = 100 - p;
def div1 = 1;
def div5 = 5;
def div25 = 25;
# ] is narrower than the vertical line
input c1 = "]";
input c5 = "]]]]]";
input c25 = "]]]]]]]]]]]]]]]]]]]]]]]]]";
#input c1 = " ";
#input c5 = " ";
#input c25 = " ";
#input c1 = "|";
#input c5 = "|||||";
#input c25 = "|||||||||||||||||||||||||";
#----------------------------
# colors
DefineGlobalColor("elapsed_c", color.green);
DefineGlobalColor("remaining_c", color.magenta);
#GlobalColor("elapsed_c")
#GlobalColor("remaining_c")
#-----------------------
# elapsed data
# divide by biggest
def eq25 = floor(p/div25);
def er25 = p % div25;
# divide by smaller
def eq5 = floor(er25/div5);
def er5 = er25 % div5;
# divide by smallest
def eq1 = floor(er5/div1);
def er1 = er5 % div1;
addlabel(1, " ", color.black);
addlabel(1, " ", color.cyan);
addlabel(1,
(if eq25 == 1 then c25 else if eq25 == 2 then c25 + c25 else if eq25 == 3 then c25 + c25 + c25 else if eq25 == 4 then c25 + c25 + c25 + c25 else "") +
(if eq5 == 1 then c5 else if eq5 == 2 then c5 + c5 else if eq5 == 3 then c5 + c5 + c5 else if eq5 == 4 then c5 + c5 + c5 + c5 else "") +
(if eq1 == 1 then c1 else if eq1 == 2 then c1 + c1 else if eq1 == 3 then c1 + c1 + c1 else if eq1 == 4 then c1 + c1 + c1 + c1 else "")
, GlobalColor("elapsed_c"));
#, color.yellow);
#-----------------------
# remaining data
# divide by biggest
def rq25 = floor(q/div25);
def rr25 = q % div25;
# divide by smaller
def rq5 = floor(rr25/div5);
def rr5 = rr25 % div5;
# divide by smallest
def rq1 = floor(rr5/div1);
def rr1 = rr5 % div1;
addlabel(1,
(if rq25 == 1 then c25 else if rq25 == 2 then c25 + c25 else if rq25 == 3 then c25 + c25 + c25 else if rq25 == 4 then c25 + c25 + c25 + c25 else "") +
(if rq5 == 1 then c5 else if rq5 == 2 then c5 + c5 else if rq5 == 3 then c5 + c5 + c5 else if rq5 == 4 then c5 + c5 + c5 + c5 else "") +
(if rq1 == 1 then c1 else if rq1 == 2 then c1 + c1 else if rq1 == 3 then c1 + c1 + c1 else if rq1 == 4 then c1 + c1 + c1 + c1 else "")
, GlobalColor("remaining_c"));
addlabel(1, " ", color.cyan);
addlabel(1, " ", color.black);
#-----------------------
addlabel(1, floor(p) + "%", color.yellow);
addlabel(1, elapsed_min + "/" + aggregation, color.yellow);
#-----------------------
# test data
input test1_elapsed = no;
addlabel(test1_elapsed , " " , color.black);
addlabel(test1_elapsed , p , color.yellow);
addlabel(test1_elapsed , " " , color.black);
addlabel(test1_elapsed , eq25 + " * " + div25 + " = " + (eq25 * div25), color.yellow);
addlabel(test1_elapsed , eq5 + " * " + div5 + " = " + (eq5 * div5), color.yellow);
addlabel(test1_elapsed , eq1 + " * " + div1 + " = " + (eq1 * div1), color.yellow);
addlabel(test1_elapsed , " " , color.black);
input test2_remaining = no;
addlabel(test2_remaining , " " , color.black);
addlabel(test2_remaining , q , color.yellow);
addlabel(test2_remaining , " " , color.black);
addlabel(test2_remaining , rq25 + " * " + div25 + " = " + (rq25 * div25), color.yellow);
addlabel(test2_remaining , rq5 + " * " + div5 + " = " + (rq5 * div5), color.yellow);
addlabel(test2_remaining , rq1 + " * " + div1 + " = " + (rq1 * div1), color.yellow);
addlabel(test2_remaining , " " , color.black);
#