将指标的价格值绘制到正确的规模?

发布于 2025-01-24 00:14:26 字数 3401 浏览 0 评论 0原文

我无法在此代码中获得线条以在左标准上显示其价格值。如何将价格值绘制到左规模?感谢您的帮助。 价值的价值

//@version=5
indicator("Lines", overlay=true, scale=scale.left)
base = input.float(title="Base Value", defval=0.7162,  step=0.0001)
lineChoice = input.string(title="Buy/Sell", defval = "Buy", options = ["Buy", "Sell", "Buy&Sell"])

if (lineChoice == "Buy")
    a = line.new(x1=bar_index, y1=base, x2=bar_index[1], y2=base, extend=extend.both, color=color.aqua, style=line.style_solid, width=1)
    b = line.new(x1=bar_index, y1=base * 1.004, x2=bar_index[1], y2=base * 1.004, extend=extend.both, color=color.aqua, style=line.style_dotted, width=1)
    c = line.new(x1=bar_index, y1=base * 1.01, x2=bar_index[1], y2=base * 1.01, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    d = line.new(x1=bar_index, y1=base * 1.02, x2=bar_index[1], y2=base * 1.02, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    e = line.new(x1=bar_index, y1=base * 1.03, x2=bar_index[1], y2=base * 1.03, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
else
    na
if (lineChoice == "Sell")
    f = line.new(x1=bar_index, y1=base, x2=bar_index[1], y2=base, extend=extend.both, color=color.purple, style=line.style_solid, width=1)
    g = line.new(x1=bar_index, y1=base * 0.996, x2=bar_index[1], y2=base * 0.996, extend=extend.both, color=color.purple, style=line.style_dotted, width=1)
    h = line.new(x1=bar_index, y1=base * 0.99, x2=bar_index[1], y2=base * 0.99, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    i = line.new(x1=bar_index, y1=base * 0.98, x2=bar_index[1], y2=base * 0.98, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    j = line.new(x1=bar_index, y1=base * 0.97, x2=bar_index[1], y2=base * 0.97, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
else
    na
if (lineChoice == "Buy&Sell")
    a = line.new(x1=bar_index, y1=base, x2=bar_index[1], y2=base, extend=extend.both, color=color.aqua, style=line.style_solid, width=1)
    b = line.new(x1=bar_index, y1=base * 1.004, x2=bar_index[1], y2=base * 1.004, extend=extend.both, color=color.aqua, style=line.style_dotted, width=1)
    c = line.new(x1=bar_index, y1=base * 1.01, x2=bar_index[1], y2=base * 1.01, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    d = line.new(x1=bar_index, y1=base * 1.02, x2=bar_index[1], y2=base * 1.02, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    e = line.new(x1=bar_index, y1=base * 1.03, x2=bar_index[1], y2=base * 1.03, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    g = line.new(x1=bar_index, y1=base * 0.996, x2=bar_index[1], y2=base * 0.996, extend=extend.both, color=color.purple, style=line.style_dotted, width=1)
    h = line.new(x1=bar_index, y1=base * 0.99, x2=bar_index[1], y2=base * 0.99, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    i = line.new(x1=bar_index, y1=base * 0.98, x2=bar_index[1], y2=base * 0.98, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    j = line.new(x1=bar_index, y1=base * 0.97, x2=bar_index[1], y2=base * 0.97, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
else
    na

I can't get the lines in this code to show their price values on the left scale. How to plot price values to the left scale? I would appreciate your help. value on a price scale

//@version=5
indicator("Lines", overlay=true, scale=scale.left)
base = input.float(title="Base Value", defval=0.7162,  step=0.0001)
lineChoice = input.string(title="Buy/Sell", defval = "Buy", options = ["Buy", "Sell", "Buy&Sell"])

if (lineChoice == "Buy")
    a = line.new(x1=bar_index, y1=base, x2=bar_index[1], y2=base, extend=extend.both, color=color.aqua, style=line.style_solid, width=1)
    b = line.new(x1=bar_index, y1=base * 1.004, x2=bar_index[1], y2=base * 1.004, extend=extend.both, color=color.aqua, style=line.style_dotted, width=1)
    c = line.new(x1=bar_index, y1=base * 1.01, x2=bar_index[1], y2=base * 1.01, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    d = line.new(x1=bar_index, y1=base * 1.02, x2=bar_index[1], y2=base * 1.02, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    e = line.new(x1=bar_index, y1=base * 1.03, x2=bar_index[1], y2=base * 1.03, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
else
    na
if (lineChoice == "Sell")
    f = line.new(x1=bar_index, y1=base, x2=bar_index[1], y2=base, extend=extend.both, color=color.purple, style=line.style_solid, width=1)
    g = line.new(x1=bar_index, y1=base * 0.996, x2=bar_index[1], y2=base * 0.996, extend=extend.both, color=color.purple, style=line.style_dotted, width=1)
    h = line.new(x1=bar_index, y1=base * 0.99, x2=bar_index[1], y2=base * 0.99, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    i = line.new(x1=bar_index, y1=base * 0.98, x2=bar_index[1], y2=base * 0.98, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    j = line.new(x1=bar_index, y1=base * 0.97, x2=bar_index[1], y2=base * 0.97, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
else
    na
if (lineChoice == "Buy&Sell")
    a = line.new(x1=bar_index, y1=base, x2=bar_index[1], y2=base, extend=extend.both, color=color.aqua, style=line.style_solid, width=1)
    b = line.new(x1=bar_index, y1=base * 1.004, x2=bar_index[1], y2=base * 1.004, extend=extend.both, color=color.aqua, style=line.style_dotted, width=1)
    c = line.new(x1=bar_index, y1=base * 1.01, x2=bar_index[1], y2=base * 1.01, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    d = line.new(x1=bar_index, y1=base * 1.02, x2=bar_index[1], y2=base * 1.02, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    e = line.new(x1=bar_index, y1=base * 1.03, x2=bar_index[1], y2=base * 1.03, extend=extend.both, color=color.aqua, style=line.style_dashed, width=1)
    g = line.new(x1=bar_index, y1=base * 0.996, x2=bar_index[1], y2=base * 0.996, extend=extend.both, color=color.purple, style=line.style_dotted, width=1)
    h = line.new(x1=bar_index, y1=base * 0.99, x2=bar_index[1], y2=base * 0.99, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    i = line.new(x1=bar_index, y1=base * 0.98, x2=bar_index[1], y2=base * 0.98, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
    j = line.new(x1=bar_index, y1=base * 0.97, x2=bar_index[1], y2=base * 0.97, extend=extend.both, color=color.purple, style=line.style_dashed, width=1)
else
    na

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

却一份温柔 2025-01-31 00:14:26

无法从line.new()绘制对象上放置标签,仅标记plot()s。

您可以将标准图与TrackPrice =参数一起使用:

//@version=5
indicator("Lines", overlay=true, scale=scale.left)
base = input.float(title="Base Value", defval=0.7162,  step=0.0001)
lineChoice = input.string(title="Buy/Sell", defval = "Buy", options = ["Buy", "Sell", "Buy&Sell"])

plot(base, 'Base', trackprice = true )
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.004 : na, 'Base * 1.004', color.aqua,   trackprice = true)
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.01 : na,  'Base * 1.01',  color.aqua,   trackprice = true)
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.02 : na,  'Base * 1.02',  color.aqua,   trackprice = true)
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.03 : na,  'Base * 1.03',  color.aqua,   trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.996 : na, 'Base * 0.996', color.purple, trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.99 : na,  'Base * 0.99',  color.purple, trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.98 : na,  'Base * 0.98',  color.purple, trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.97 : na,  'Base * 0.97',  color.purple, trackprice = true)

”在此处输入图像说明”

There is no way to place a label on the scale from the line.new() drawing objects, only plot()s are labeled.

You can use the standard plots instead with a trackprice= argument:

//@version=5
indicator("Lines", overlay=true, scale=scale.left)
base = input.float(title="Base Value", defval=0.7162,  step=0.0001)
lineChoice = input.string(title="Buy/Sell", defval = "Buy", options = ["Buy", "Sell", "Buy&Sell"])

plot(base, 'Base', trackprice = true )
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.004 : na, 'Base * 1.004', color.aqua,   trackprice = true)
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.01 : na,  'Base * 1.01',  color.aqua,   trackprice = true)
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.02 : na,  'Base * 1.02',  color.aqua,   trackprice = true)
plot(lineChoice == "Buy"  or lineChoice == "Buy&Sell"? base * 1.03 : na,  'Base * 1.03',  color.aqua,   trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.996 : na, 'Base * 0.996', color.purple, trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.99 : na,  'Base * 0.99',  color.purple, trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.98 : na,  'Base * 0.98',  color.purple, trackprice = true)
plot(lineChoice == "Sell" or lineChoice == "Buy&Sell"? base * 0.97 : na,  'Base * 0.97',  color.purple, trackprice = true)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文