#Exampl_Red_Candle_Count_RTH
input showbubbles = yes;
input showlabel = yes;
def red = if !(SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600) > 0)
then 0
else if SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600) > 0 and open > close
then red[1] + 1
else red[1];
def all = if !(SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600)>0)
then 0
else if SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600) > 0
then all[1] + 1
else all[1];
AddChartBubble(showbubbles and SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0,
high * 1.0025,
"Red: " + red +
"\nRTH: " + all +
"\n%Red: \n" + AsPercent(red/all),
if open > close then Color.RED else color.gray, yes);
def redtoday = highestall(if GetDay() == GetLastDay() then red else Double.NaN);
def alltoday = if secondsfromTime(1600)<0 then all else highestall(all);
AddLabel(showlabel and GetDay() == GetLastDay(),
"Today: " + asprice(getyyyYMMDD()) +
" | Red: " + redtoday +
" | RTH: " + alltoday+
" | %Red: " + AsPercent(redtoday/alltoday),
if secondsfromTime(1600)<0 and open < close then color.gray else Color.RED);