简体   繁体   中英

Percentage Change function in pine-script

Is there a function in pine like pct_change() in python, which can calculate percentage change in pine? Since there is not data management system

roc(source, length) will return 0.5 for 50%.

So, firstly, there's the function ta.change , which is a difference between current value and the value n bars back in a series. Secondly, there's also the Momentum function ta.mom , which is change in price specifically. Thirdly, there is a function Rate of Change ta.roc , which is Momentum normalised to the price n bars back. Fourthly, you can write your own to have said Momentum normalised to the current price if you prefer:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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