如何使用带有 ichimoku 基线价格的线

How use a hline with icimoku base line price

嗨,我需要获取基准价格并在图表中显示 Hline(不需要图表价格(收盘价、低价...),我只需要 icimoku 基准价格)这是我的代码

我的错误: 第 10 行:无法使用 'price'=series[float] 调用 'hline'。参数的类型应该是:input float

代码:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © WorldNull

//@version=4
study("t_01",overlay=true)
basePeriods = input(103, minval=1, title="Base Line Length")
donchian(len) =>avg(lowest(len), highest(len))
bs = donchian(basePeriods)
bsw=(bs == bs[1]) and (bs==bs[2])
hline(bs)
plot(bs)

hline() 不能接受逐条变化的系列类型,例如 closebs,只能接受静态输入值或设置值,例如 hline(30)

您可以将 trackprice = trueplot()

一起使用
plot(bs, trackprice = true)

或使用像这样的线函数,它可以让您更好地控制样式、颜色等,而不必绘制正常移动的非水平线

f_hline(_price, _color, _style, _width) =>
    _t2 = int(time + change(time))
    var line _line = line.new(x1 = time, y1 = _price, x2 = _t2, y2 = _price, xloc = xloc.bar_time, color = _color, style = _style, width = _width, extend = extend.both)
    line.set_xy1(_line, x = time, y = _price)
    line.set_xy2(_line, x = _t2, y = _price)

f_hline(bs, color.red, line.style_dashed, 1)