在 Pine Script 上更改已创建 "plotshape" 的位置

Changing position of created "plotshape" on Pine Script

“RSI 买入”或“RSI 卖出”信号直接出现在柱线上方或下方,有时难以阅读。是否可以更改图表上y轴的位置。

enter code here

//@version=4
study(title="Relative Strength Index", overlay=true, shorttitle="RSI Signals")

srcRSI = close
lenRSI = input(14, minval=1, title="Length")

//method color[enter image description here][1]
srcRSI1 = close
lenRSI1 = input(70, minval=1, title="RSI Up Standard")
srcRSI2 = close
lenRSI2 = input(30, minval=1, title="RSI Down Standard")

upRSI = rma(max(change(srcRSI), 0), lenRSI)
downRSI = rma(-min(change(srcRSI), 0), lenRSI)

rsiRSI = downRSI == 0 ? 100 : upRSI == 0 ? 0 : 100 - 100 / (1 + upRSI / downRSI)

isup() =>
    rsiRSI[1] > lenRSI1 and rsiRSI <= lenRSI1
isdown() =>
    rsiRSI[1] < lenRSI2 and rsiRSI >= lenRSI2

plotshape(isup(), color=#FF0000, style=shape.triangledown, text="RSI Sell", textcolor=#FF0000, location=location.abovebar, size=size.tiny)
plotshape(isdown(), color=#009900, style=shape.triangleup, text="RSI Buy", textcolor=#009900, location=location.belowbar, size=size.tiny)

plotshape()location= 参数替换为 location.absolute 并为标签添加任意 y(价格)位置 (high + atr(10) / low - atr(10)),如下例所示:

plotshape(isup()? high + atr(10) : na, color=#FF0000, style=shape.triangledown, text="RSI Sell", textcolor=#FF0000, location=location.absolute, size=size.tiny)
plotshape(isdown()? low - atr(10) : na, color=#009900, style=shape.triangleup, text="RSI Buy", textcolor=#009900, location=location.absolute, size=size.tiny)