[英]Calculate length between bar_index in pinescript
想要计算test_X1
bar 和bar_index
之间的最高close
价,然后是plot这条线,前提是最高close
价不大于test_y
增加 10%
当我尝试使用highest()
时,它希望我使用 integer 值作为length
, bar_index-test_x1
仍然是一个系列。
//@version=4
study(title="Test", shorttitle="Test", format=format.volume, overlay=true)
var line hline = line.new(na, na, na, na, extend=extend.right, color=color.white)
var test_y = -1.0
var test_x1 = -1.0
if close > close[2]
line.set_xy1(hline, bar_index - 20, close)
line.set_xy2(hline, bar_index, close)
test_y := close
test_x1 := bar_index
像这样?
//@version=4
study(title="Test", shorttitle="Test", format=format.volume, overlay=true)
var bars_back = input(20)
var line hline = line.new(na, na, na, na, extend=extend.right, color=color.white)
hc = highest(close, bars_back)
if barstate.islast and (close <= hc * 1.1)
line.set_xy1(hline, bar_index - bars_back, hc)
line.set_xy2(hline, bar_index, hc)
else
line.set_xy1(hline, na, na)
line.set_xy2(hline, na, na)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.