# first_signal_in_year_0
#https://usethinkscript.com/threads/scanner-for-new-yearly-low.16055/
declare lower;
def na = double.nan;
def bn = barnumber();
#def newday = getday() != getday()[1];
def newyear = getyear() != getyear()[1];
input lo_level = 5.00;
def lolo = if low < lo_level then 1 else 0;
def lolonum = if newyear then 0
else if lolo then getday()
else lolonum[1];
def firstlownum = if newyear then 0
else if firstlownum[1] > 0 then firstlownum[1]
else if lolo then getday()
else firstlownum[1];
def firstlolo = if firstlownum == getday() then 1 else 0;
# first signal
plot z1 = firstlolo + 0.25;
#all signals
input show_all_signals = no;
plot z2 = if !show_all_signals then na
else if bn == 1 then -1.25 else if lolo then -0.25
else -1.25;
addverticalline( newyear, "-", color.cyan);
#---------------------------
addchartbubble(0, 0,
lolo + "\n" +
lolonum + "\n" +
firstlownum + "\n" +
firstlolo + "\n"
, (if firstlolo then color.yellow else color.gray), no);
#