将变量价格(price)减去500,形成一个水平线,坐标为(price – 500)。

huangapple go评论67阅读模式
英文:

How to make the variable price - 500, formed not as a curve, but as a horizontal line with coordinates (price - 500)

问题

I can help you with the translation of the code and the associated text. Here's the translated content:

Demonstration of the problem

在使用变量进行计算时,我不知道如何获得水平线。请查看附加的图片。此外,需要的是变量,而不是通过绘图函数输出的数据。

//@version=5
indicator(title="交叉", shorttitle="INTR", overlay=true, max_bars_back=100)

a = 44626
plot(a, '1', color=color.white)
//我该如何在计算过程中获得水平线,而不是曲线a1,而是a。
a1 = close - 1000
plot(a1, '1', color=color.red)

请注意,我已将HTML编码("')替换为普通引号以使代码更易读。如果需要进一步帮助,请告诉我。

英文:

Demonstration of the problem

I don't know how to get the horizontal line when using the calculations for the variable. Please see the attached picture.Moreover, it is the variable that is needed, and not the output of data through the plot function.

//@version=5
indicator(title="intersection", shorttitle="INTR",overlay = true, max_bars_back = 100)

a = 44626
plot(a, '1', color = color.white)
//How can I make it so that during calculations I get not a curve but a horizontal line? those. when calculating the output, not the curve a1, but a.
a1 = close - 1000
plot(a1, '1', color = color.red)

答案1

得分: 0

两种方法来实现这个。使用 hlineline.new

//@version=5
indicator(title="交叉", shorttitle="交叉", overlay=true, max_bars_back=100)

a = 44626
plot(a, '1', color=color.blue)
//如何使得在计算过程中得到的不是曲线而是水平线?也就是说,在输出计算时不是曲线 a1,而是 a。
a1 = close - 1000
plot(a1, '1', color=color.red)
// hline 方法
hline(a, 'A HLine', color=color.blue)
//line.new 方法
if barstate.islast
    line.new(bar_index, a1, bar_index + 1, a1, extend=extend.both)
英文:

Two ways to do that. Using an hline or a line.new

//@version=5
indicator(title="intersection", shorttitle="INTR",overlay = true, max_bars_back = 100)

a = 44626
plot(a, '1', color = color.blue)
//How can I make it so that during calculations I get not a curve but a horizontal line? those. when calculating the output, not the curve a1, but a.
a1 = close - 1000
plot(a1, '1', color = color.red)
// hline way
hline(a,'A HLine', color.blue)
//line.new way
if barstate.islast
    line.new(bar_index, a1, bar_index + 1, a1, extend = extend.both)

huangapple
  • 本文由 发表于 2023年5月25日 16:45:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76330404.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定