【发布时间】:2021-12-30 07:41:33
【问题描述】:
Trading View Pine 脚本:如何在不使用偏移的情况下左移指标?
右移效果很好。
左移有问题
//@version=5
indicator("right_left_shift", overlay=true)
shift = close
plot(shift)
plot(shift[25], color=color.green) //right shift correct
plot(shift[-25], color=color.red) //how to do left shift, without using offset?
错误:索引不能为负值
【问题讨论】:
-
为什么不想使用 offset 参数? pine 中的 [] 称为历史引用运算符,不能为负索引。
-
因为我想直接对25个周期的左移收盘进行计算
-
偏移只是移动线本身,它不会使用之前蜡烛的值。如果您想在计算中使用历史数据,您应该使用
[]运算符。如果你想得到25根柱线前的收盘价,可以close[25]。
标签: pine-script trading pine-script-v4 pinescript-v5