How to delete repeating labels in pinescript?

Viewed 18

How can i delete these repeating shapes? I want "Buy" labels to appear when the line turns green, and "Sell" when it turns red

//@version=4
study("Test", overlay = true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)

emaslow3 = input(21,title='EMA-Slow')
srcfast = input(open)


bjemaslow3 = ema(srcfast, emaslow3)
up3 = bjemaslow3 > bjemaslow3 [1]
down3 =bjemaslow3 < bjemaslow3[1]
mycolor3 = up3 ? #15dd03 : down3 ? #d32f2f : na


emaslowplot3 = plot(bjemaslow3, color=mycolor3, transp=35, title='EMA-21', linewidth = 2)

plotshape(showsignals and mycolor3 == #15dd03 ? 1 : na, title="Buy", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
plotshape(showsignals and mycolor3 == #d32f2f ? 1 : na, title="Sell", text="Buy", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)

https://i.stack.imgur.com/YL6Sp.png

0 Answers
Related