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
Asked
Active
Viewed 1.0k times
3

Slartibartfast
- 1,058
- 4
- 26
- 60
-
1There is a `change()` function but it just gives the difference between the current value and some previous value. You have to write your own. – vitruvius May 15 '20 at 08:44
2 Answers
4
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

Alejandro
- 41
- 4