BacktestRookies

Percentage Change Function

This is little code snippet can be copied and pasted into your own strategies and indicators to easily calculate some interesting percentage change levels within a given lookback period.

The function will return:
  • The price change from the start to the end of the period
  • The price change from the start of the period to the highest point within the period
  • The price change from the start of the period to the lowest point within the period

It was originally intended to be used in conjunction with other scripts to assist with decision making. However, it doesn't look too bad as an indicator and so plots have been added.

For more information regarding the code, some commentary and free tutorials, you can visit the Bactest-Rookies (.com) website.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Comments

Hi.. I loved this indicator. Is there any way to use this logic in algo trading? If you can provide some kind of condition would be much much appreciated. Thanks.
Reply
how to create an alert condition here
Reply
How would I apply this to something like volume?
Reply
Is there a way to loop three seperate lookback periods? say 5 10 20?

'inp_lkb = input(5,10,20 title='Lookback Periods')
for each(Lookback_Periods =>

and then maybe some logic to determine if price is narrowing or expanding to open a window for a trade?

Reply
BacktestRookies JustTheCharts
Hi @JustTheCharts,
Yes - you could just have three separate inputs and call the function 3 times. An input() cannot return a list as far as I am aware, so you would need 3 separate ones.
+2 Reply
JustTheCharts BacktestRookies
@BacktestRookies, Thank you... its a matter of time before im going to give in and pay you for what i need.
+2 Reply