Hi Roberto, I was comparing barsSince with a basic count and got some differing results.
The count values presented regarding the true conditions are the same.
However, the lines plotted are different.
It appears that barsSince counts from the last count value of the last true condition, then jumps to the correct new count value level on next true condition.
This means the prior value [1],[2] etc wouldn’t be representing the correct prior values of the count.
Is this the intended operation or is there something more to it.
If using a basic count , the prior values are relevant between counts for prior values.
// images - IG DAX German 40 DFB
avg = average[34,0](close)
c1 = close crosses over avg
//------------------- XCOUNT
xcount = xcount+1
if c1 then
// true condition Vline
drawvline(barindex)coloured("red",100)style(dottedline,1)
// Xcount Value Label
drawtext(xcount[0],barindex[1],50)anchor(bottom,index,yshift)coloured("aqua")
m1xcount = xcount[1]
drawtext("[ #m1xcount#]",barindex[2], 30)anchor(bottom,index,yshift)coloured("aqua")
endif
if c1 then
xcount=0
xbar = barindex
endif
//------------------- BARSSINCE
bs=barssince(c1,1)
if c1 then
// barsSince Value Label
drawtext(bs,barindex[1],-50)anchor(top,index,yshift)coloured("violet")
m1bs = bs[1]
drawtext("[ #m1bs#]",barindex[2],-30)anchor(top,index,yshift)coloured("violet")
endif
// header Labels
if barindex = 0 then
drawtext("barsSince",0,-20)anchor(top,xshift,yshift)coloured("violet")
drawtext("Xcount",0,20)anchor(bottom,xshift,yshift)coloured("aqua")
endif
return xcount coloured("aqua") as"Xcount",bs coloured("violet") as"barSince"//,xbar