我想在我的 TradingView 图表上叠加文字。我想在 RSI 85 的水平位显示“超买”,并以白色居中,并在 RSI 15 的水平位显示“超卖”。但我不知道该怎么做。标签或文字显示 RSI 85 的水平位超买,RSI 15 的水平位超卖。谁能帮我实现一下,谢谢
我如何添加文本?
这是我目前拥有的代码:
//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")
len = input(14, minval=1, title="Length")
src = input(close, "Source", type = input.source)
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, "RSI", color=color.rgb(255, 255, 255))
band6 = hline (85, "upper band2", color=#ffffff70,linestyle=hline.style_dotted, linewidth=1)
band5 = hline (70, "upper Band3", color=#ffffff70,linestyle=hline.style_dotted, linewidth=1)
band4 = hline (60, "upper band4", color=#ffffff70,linestyle=hline.style_dotted, linewidth=1)
band2 = hline (30, "lower band2", color=#ffffff70,linestyle=hline.style_dotted, linewidth=1)
band1 = hline (15, "lower band3", color=#ffffff70,linestyle=hline.style_dotted, linewidth=1)
band0 = hline (00, "lower band4", color=#ffffff70,linestyle=hline.style_dotted, linewidth=1)
到目前为止,我的图表是这样的:
首先,将 v4 升级到 v5
https://www.tradingview.com/pine-script-docs/migration-guides/overview/
要使图表居中,您可以使用 chart.right_visible_bar_time 和 chart.left_visible_bar_time
https://www.tradingview.com/pine-script-reference/v6/#var_chart.right_visible_bar_time
类似这样的: