我想包括一个文本输入功能,以添加文本到水平线/线,我正在策划的变化率指标。这些线路本质上就像70/30的RSI超买和超卖线路,但我用它们作为概率区域。我想要能够写在文字,将显示在每一行的情节。Tradingview提供了一个带有文本输入和选项的自定义水平线绘图工具,用于将文本对齐到右、中或左。我希望将这些特征包括在变化率指标中,其中包括一组标有概率区域的水平线。谢谢你的帮助
//@version=5
indicator(title="Rate Of Change", shorttitle="ROC-w-prb-lne", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(1, minval=1)
source = input(close, "Source")
roc = 100 * (source - source[length])/source[length]
plot(roc, color=#2962FF, title="ROC-w-probty ln")
hline(0.5, color=#edde35, title="50% (+25%) prob Line")
hline(-0.5, color=#edde35, title="50% (-25%) prob line")
hline(1.0, color=#2950de, title="75% (+38%) Line")
hline(-1.0, color=#2950de, title="75% (-36%) Line")
hline(2.5, color=#787B86, title="95% (+48%) line")
hline(-2.5, color=#787B86, title="95% (-48%) line")
hline(3.5, color=#c73030, title="98% (+49%) line")
hline(-3.5, color=#c73030, title="98% (-49%) line")
发布于 2022-11-13 21:59:30
如果你想显示一些文字,你应该使用“标签”。将其y
参数设置为您的hline
值,并根据您的意愿操作x
参数。
您可以使用bar_index
、chart.left_visible_bar_time
或chart.right_visible_bar_time
来操作x
坐标。
以下是一些例子:
//@version=5
indicator("My script")
hline_price_1 = 100
hline_price_2 = 75
hline_price_3 = 50
hline_price_4 = 25
hline(hline_price_1)
hline(hline_price_2)
hline(hline_price_3)
hline(hline_price_4)
label hline_label_1 = label.new(bar_index, hline_price_1, str.tostring(hline_price_1), style=label.style_none, textcolor=color.white)
label hline_label_2 = label.new(bar_index - 50, hline_price_2, str.tostring(hline_price_2), style=label.style_none, textcolor=color.white)
label hline_label_3 = label.new(chart.left_visible_bar_time, hline_price_3, str.tostring(hline_price_3), xloc=xloc.bar_time, style=label.style_none, textcolor=color.white)
label hline_label_4 = label.new(chart.right_visible_bar_time, hline_price_4, str.tostring(hline_price_4), xloc=xloc.bar_time, style=label.style_none, textcolor=color.white)
label.delete(hline_label_1[1])
label.delete(hline_label_2[1])
label.delete(hline_label_3[1])
label.delete(hline_label_4[1])
https://stackoverflow.com/questions/74424561
复制相似问题