如何在交易视图脚本中在收盘价上方或下方画一条x点线?



如何创建一条直线加上其上方的常量值的指示器?我的想法是,我想展示我的经纪人价格与交易价值的比较。到目前为止,我只画了一条水平线:

//@version=5
indicator("Close+Constant", overlay=true)
if barstate.islast
line.new(bar_index[10], close, bar_index, close, width = 2, color = color.blue,  extend = extend.both)

但是尝试给bar_index[10](例如)添加一个常量float会给出一个类型错误,期望是int但得到float。

现有的解决方案导致相同的错误:

Cannot call 'hline' with argument An argument of 'series float' type was used but a 'input float' is expected

你必须在line:

//@version=5
indicator("Close+Constant", overlay=true)
spread = 0.005 // Adjust your spread with the one from your broker
if barstate.islast
line.new(bar_index[10], close + spread, bar_index, close + spread, width = 2, color = color.blue,  extend = extend.both)

最新更新