【发布时间】:2021-12-17 08:47:13
【问题描述】:
fold manual 举个例子:
input price = close;
input length = 9;
plot SMA = (fold n = 0 to length with s do s + getValue(price, n, length - 1)) / lenth;
这有效地迭代调用函数,就像在 for 循环体中一样。
当我使用这个语句来调用我自己的函数时,它会中断,因为循环索引变量没有被识别为可以传递给我的函数的变量:
script getItem{
input index = 0;
plot output = index * index;
}
script test{
def total = fold index = 0 to 10 with accumulator = 0 do
accumulator + getItem(index);########## Error: No such variable: index
}
【问题讨论】:
标签: thinkscript