简体   繁体   English

更改 Pine Script 上创建的“plotshape”的位置

[英]Changing position of created “plotshape” on Pine Script

The signals "RSI Buy" or "RSI Sell" appears directly above or below the bar and sometimes it's difficult to read it. “RSI 买入”或“RSI 卖出”信号直接出现在柱线上方或下方,有时很难阅读。 Is it possible to change the position in the y-axis on the chart.是否可以更改图表上 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)

Replace the plotshape() 's location= arguments of with location.absolute and add any y (price) location for the label ( high + atr(10) / low - atr(10) ), as is shown in the example below: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)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM