简体   繁体   English

松树脚本中的百分比变化 function

[英]Percentage Change function in pine-script

Is there a function in pine like pct_change() in python, which can calculate percentage change in pine?松树中是否有像 python 中的pct_change()一样的 function,它可以计算松树的百分比变化? Since there is not data management system由于没有数据管理系统

roc(source, length) will return 0.5 for 50%. roc(source, length)将返回 50% 的 0.5。

So, firstly, there's the function ta.change , which is a difference between current value and the value n bars back in a series.所以,首先,有 function ta.change ,它是当前值与一系列后面的 n 条柱值之间的差值。 Secondly, there's also the Momentum function ta.mom , which is change in price specifically.其次,还有 Momentum function ta.mom ,具体是价格变化。 Thirdly, there is a function Rate of Change ta.roc , which is Momentum normalised to the price n bars back.第三,有一个 function 变化率ta.roc ,它是归一化到价格 n 根柱线的动量。 Fourthly, you can write your own to have said Momentum normalised to the current price if you prefer:第四,如果您愿意,您可以自己编写将 Momentum 标准化为当前价格:

nmom = 100 * ta.mom(price, n) / price

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM