g1 = ta.barssince(close <= adj_bollinger1 or close <= adj_bolliner2)
g2 = ta.barssince(close >= adj_bollinger1 or close >= adj_bolliner2)
if close > adj_bollinger1 and close > adj_bolliner2
closeUPDWBollinger := green
barsSinceCloseHupdwBollinger := g1
else if close < adj_bollinger1 and close < adj_bolliner2
closeUPDWBollinger := red
barsSinceCloseHupdwBollinger := g2
else
closeUPDWBollinger := color.gray
barsSinceCloseHupdwBollinger := -0
Essentially, I want to know the number of bars since close is outside upper/lower Bollinger.
Problem arises when the bar count continues despite close going back inside and closing AND then the next bar going back out again to make the condition true.
I want it to reset to zero and continue on from that dip. Sometimes it only starts counting a few bars AFTER the condition had been true.
Thank you.