Pine 脚本标签问题,如何防止我编写的代码在每个蜡烛下放置标签?

Pine script tag problem, how can I prevent the code I write from putting tags under each candle?

如何防止我的代码在每根蜡烛下放置标签。谢谢

//@version=5
indicator('$ Control ema ver.', overlay=true)

len50 = input.int(5, minval=1, title='EMA')
src50 = input(close, title='Source')
out50 = ta.ema(src50, len50)

all = close >= out50 
satt = close <= out50 

plotshape(all, title='Buy', text='¡', location=location.belowbar, style=shape.labelup, 
size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))  

plotshape(satt, title='Sel', text='!', location=location.abovebar, style=shape.labeldown, 
size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))

您可以做的一个技巧是检查您的条件是否在前一个柱上不为真,而在当前柱上是否为真。这样你就会知道你的信号状态已经改变了。

//@version=5
indicator('Control ema ver', overlay=true)

len50 = input.int(5, minval=1, title='EMA')
src50 = input(close, title='Source')
out50 = ta.ema(src50, len50)

all = close >= out50
satt = close <= out50

buy = not all[1] and all
sell = not satt[1] and satt

plotshape(buy, title='Buy', text='¡', location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))  
plotshape(sell, title='Sel', text='!', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))