In this code, I am getting the Green and red candle Counts being overwritten and it's not clearly shown in the chart and it leaves out the first candles at the market open time.. Guys, I want the gren and red candle counts separately including the first candle at the market open time and i dont want the overwritten counts and I want the correct counts..I am just a beginner..Please help me on this one..Thanks..
plot(close)
t = ta.change(time('D'))
up = close > open ? 1 : 0
dn = close < open ? 1 : 0
a = 0.
a := t ? up : a[1] + up
b = 0.
b := t ? dn : b[1] + dn
label.new(bar_index, high, str.tostring(a), textcolor=color.blue, style=label.style_none)
label.new(bar_index, high, str.tostring(b), textcolor=color.blue, style=label.style_none)