【发布时间】:2021-06-29 10:42:12
【问题描述】:
我正在尝试计算一个长度变化的简单移动平均线(从特定点开始,每根柱线在指标计算长度上加 1),以便在 bar0 时刻指标长度为 1,在 bar1 时刻长度为2等。
我不一定需要在图表上看到它,但我想不出另一种方法可以确保计算正确。
//@version=4
study("My Script")
src = close
a = sma(src, 5)
cal = barssince(a > 29000)
len = cal == 0 ? 1 : cal // there shouldn't be any 0 values from the above function but just to make sure.
plot(len) // works
b = sma(src, len) // this line also works (at least there are no errors) but plotting it on the chart doesn't work
plot(b)
错误(我还不能发布图片): 研究错误 “sma”函数中的“length”参数 (0.0) 的值无效。它必须 > 0。
【问题讨论】:
标签: pine-script