如何在打开 /关闭上绘制水平线(' hlines')?

发布于 2025-01-21 09:12:38 字数 464 浏览 4 评论 0原文

我刚刚开始使用Pine-Script,并在绘制供应区域的指标时遇到了我的第一个问题。由于关闭和打开是系列类型,因此由于以下错误,我无法在Hline函数中使用它们 -

第19行:无法用参数'Price'='Call'Call'call'运算符SQBR'(系列float)调用'hline''(系列float)'。使用了“系列浮点”类型的参数,但是预期有“输入浮点”

是否可以将串联类型转换为输入类型或可以与系列类型一起绘制HLINE的替代功能的工作?

indicator("My script")

if close > open 
    onePercentClose  = close / 100
    diff = close - open
    if diff > onePercentClose
        hline(close[1])
        hline(open[1])

I have just started working with pine-script and run into my first issue whilst working on an indicator that plots supply/demand zones. Because close and open are series types I cannot use them within the hline function due to the following error -

line 19: Cannot call 'hline' with argument 'price'='call 'operator SQBR' (series float)'. An argument of 'series float' type was used but a 'input float' is expected

Is there a work around to convert series types into input types or an alternative function that can be used with series types to plot the hlines?

indicator("My script")

if close > open 
    onePercentClose  = close / 100
    diff = close - open
    if diff > onePercentClose
        hline(close[1])
        hline(open[1])

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

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

发布评论

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

评论(1

青萝楚歌 2025-01-28 09:12:38

否,hline()无法基于串联值创建行。该值必须在编译时已知。如果要绘制水平线,则可以使用常规plot()函数绘制图或line.new()函数来绘制行对象。

//@version=5
indicator("My script", overlay=true)

float h = na
if close > open 
    onePercentClose  = close / 100
    diff = close - open
    if diff > onePercentClose
        h := close[1]
        l = line.new(bar_index[1], open[1], bar_index, open[1])
        
plot(h, style = plot.style_linebr)

No, hline() cannot create lines based on series values. The value must be known at compile time. If you want to plot horizontal lines, you can use either the regular plot() function to draw plots or the line.new() function to draw line objects.

//@version=5
indicator("My script", overlay=true)

float h = na
if close > open 
    onePercentClose  = close / 100
    diff = close - open
    if diff > onePercentClose
        h := close[1]
        l = line.new(bar_index[1], open[1], bar_index, open[1])
        
plot(h, style = plot.style_linebr)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文