pine-script 中的百分比变化函数

Sla*_*ast 3 pine-script

pine 中是否有像 python 中那样的函数pct_change(),可以计算 pine 的百分比变化?由于没有数据管理系统

Pin*_*ucF 7

roc(source, length)50% 将返回 0.5。


Ale*_*dro 5

因此,首先是函数ta.change,它是当前值与一系列中的 n 个柱的值之间的差值。其次,还有动量函数ta.mom,具体来说就是价格的变化。第三,有一个函数“变化率” ta.roc,它是标准化为 n 个柱状图价格的动量。第四,如果您愿意,您可以自己编写将动量标准化为当前价格:

nmom = 100 * ta.mom(price, n) / price
Run Code Online (Sandbox Code Playgroud)