从时间戳获取收盘价
Get closed price from a timestamp
手册讨论了如何从蜡烛的收盘价中获取时间戳,但是如何根据时间戳获取收盘价?
假设我想从当前蜡烛中获取第 5 根蜡烛的收盘价。谢谢
可以在您的变量后面使用历史运算符 [x] 来引用第五根蜡烛。例如。收盘价 5 柱前是收盘价[5].
var bool already_stored = false
var float price = na
var int ts = na
var label mylabel = label.new(x = na, y = na, xloc = xloc.bar_time)
if barstate.islast and not already_stored
price := close[5]
ts := time[5]
label.set_xy(mylabel, x = ts, y = price)
already_stored := true
手册讨论了如何从蜡烛的收盘价中获取时间戳,但是如何根据时间戳获取收盘价?
假设我想从当前蜡烛中获取第 5 根蜡烛的收盘价。谢谢
可以在您的变量后面使用历史运算符 [x] 来引用第五根蜡烛。例如。收盘价 5 柱前是收盘价[5].
var bool already_stored = false
var float price = na
var int ts = na
var label mylabel = label.new(x = na, y = na, xloc = xloc.bar_time)
if barstate.islast and not already_stored
price := close[5]
ts := time[5]
label.set_xy(mylabel, x = ts, y = price)
already_stored := true