I’m not sure about your query, but I think you want the text to be switch off with a setting, which I implement in the below version (setting is “showtext”, default state is OFF).
defparam drawonlastbaronly=true
p = 20
maxbars = 800 //how many bars in history?
reversedCandles = 5 //levels have been the same during X bars
reversedPoints = 2 //current level - previous level > Y points
showtext = 0 //show levels text
if barindex > p then
hh= highest[p](high)
ll= lowest[p](low)
if hh<>hh[1] and hh[1]>0 and hh[1]=hh[1+reversedCandles] and abs(hh-hh[1])>=reversedPoints*pointsize then
$hhprice[hhi]=hh
$hhbar[hhi]=barindex[1+reversedCandles]
hhi=hhi+1
endif
endif
if islastbarupdate and hhi>0 then
//plot the hh lines
for i = 0 to hhi-1 do //loop through levels
elapsed = barindex-$hhbar[i]
if elapsed>1 and elapsed<=maxbars then
offset = max(0,barindex-$hhbar[i])
for j = 0 to offset do //testing price break of the current level
price1 = close[j]
priceprev = close[j+1]
level = $hhprice[i]
broken = 0
if (price1>level and priceprev<level) or (price1<level and priceprev>level) then
broken=1
//drawarrow($hhbar[i],price)
break
endif
next
if broken=0 then
drawsegment($hhbar[i],$hhprice[i],barindex,$hhprice[i])COLOURED(255,0,0)
test=$hhprice[i]
if showtext then
drawtext("#test#",barindex,$hhprice[i],serif,bold,20)COLOURED(255,0,0)
endif
//drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)
endif
endif
next
endif
if barindex > p then
ll= lowest[p](low)
hh= highest[p](high)
if ll<>ll[1] and ll[1]>0 and ll[1]=ll[1+reversedCandles] and abs(ll-ll[1])>=reversedPoints*pointsize then
$llprice[lli]=ll
$llbar[lli]=barindex[1+reversedCandles]
lli=lli+1
endif
endif
// ___________________________
if islastbarupdate and lli>0 then
//tracer les lignes ll
for i = 0 to lli-1 do //boucle à travers les niveaux
elapsed = barindex-$llbar[i]
if elapsed>1 and elapsed<=maxbars then
offset = max(0,barindex-$llbar[i])
for j = 0 to offset do //tester la rupture de prix du niveau actuel
price1 = close[j]
priceprev = close[j+1]
level = $llprice[i]
broken = 0
if (price1<level and priceprev>level) or (price1>level and priceprev<level) then
broken=1
//drawarrow($hhbar[i],price)
break
endif
next
if broken=0 then
drawsegment($llbar[i],$llprice[i],barindex,$llprice[i])COLOURED(0,128,0)
test=$llprice[i]
if showtext then
drawtext("#test#",barindex,$llprice[i],serif,bold,20)COLOURED(0,128,0)
endif
//drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)
endif
endif
next
endif
return