获取“无法使用参数 'price'='level' 调用 'hline'。使用了 'series int' 类型的参数,但需要 'input float'。”用松笔写的

问题描述 投票:0回答:1
//@version=5
indicator("My script", overlay = true)
var o = 21304
hline(o, "OPEN PRICE", color.green, hline.style_solid, 1, true)

var rg = 100

for  i = -rg to rg
    var level = o + i
    if (level % 100 == 0)
        hline(level, "p", color.green, hline.style_solid, 2)

我想根据某个级别的值在图表上绘制一条水平线,但我在上面的代码中遇到了上述错误

正如使用pine脚本的hline函数在图表中绘制的绿线一样:

Exactly like the green line drawn in the chart using the hline function of pine script

pine-script pine-script-v5 trading pine-script-v4
1个回答
0
投票

hline()
函数不能在
if
/
for
块的局部范围内调用,请使用
line.new()
代替:

//@version=5
indicator("My script", overlay = true)
var o = 21304
hline(o, "OPEN PRICE", color.lime, hline.style_solid, 1, true)

var rg = 100
for  i = -rg to rg
    level = o + i
    if (level % 100 == 0)
        line.new(bar_index, level, bar_index +1, level, xloc.bar_index, extend.both, color.red, line.style_solid, 2)

© www.soinside.com 2019 - 2024. All rights reserved.