I have this script to make the current, unclosed bar transparent
//@version=4
study("", "", true)
i_transp = 80
barcolor(barstate.islast ? close > open ? color.new(color.teal, i_transp) : color.new(color.red, i_transp) : na)
The problem is the candle stays transparent even when a new one appears, until I refresh the page. Can I do this automatically with pine script? Or is there a way to change any closed candles to solid colour?
Thank you!
Don't know why
barstate.islast
is not working in this example (as well asbarstate.isrealtime
,barstate.ishistory
- all combination of those have the same issue).But I found the way to achieve your goal by using
barstate.isconfirmed
: