【发布时间】:2020-08-15 19:17:44
【问题描述】:
我目前正在尝试在 Pine Script 中为 TradingView 编写脚本,但在绘制仅在最后收盘价/时间和图表末尾之间绘制的水平线时遇到了困难。附图片供参考。 Link
我目前正在尝试使用 line.set 和 line.new,以便我可以接受自定义价格输入并将语句放入 if 函数中。
我们将不胜感激。
此处附上代码,可选择在整个图表上画一条线或仅如上。
show1 = input(true, title="|- Use Line1?")
dS1 = input(true, title="|- Short Line1")
price1 = input(title="Price1", type=input.integer, defval=0)
var line l1 = na
if show1
line.set_x2(l1, bar_index)
line.set_extend(l1, extend.none)
line.set_color(l1, color.green)
line.set_style(l1, line.style_solid)
line.set_width(l1, 2)
if dS1
l1 := line.new(bar_index, price1, bar_index, price1, extend=extend.right)
else
l1 := line.new(bar_index, price1, bar_index, price1, extend=extend.both)
label label1 = label.new(bar_index, price1, "Line1", textcolor=color.green, style=label.style_none), label.delete(label1[1])
【问题讨论】:
-
这里的答案通常是代码修复,因此它们需要代码。你试过什么代码?
-
用我的代码编辑了我的帖子。谢谢:)
标签: pine-script horizontal-line