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?


how to create an alert condition here
How would I apply this to something like volume?
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?

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 Svara
JustTheCharts BacktestRookies
@BacktestRookies, Thank you... its a matter of time before im going to give in and pay you for what i need.
+2 Svara
Hem Aktie-screener Forex-screener Krypto-screener Ekonomisk kalender Om Diagramfunktioner Priser Tipsa en vän Ordningsregler Hjälpcenter Webbsidor och mäklarlösningar Widgets Diagramlösningar Lightweight Charting Library Blogg och nyheter Twitter
Profil Profilinställningar Konto och fakturering Hänvisade vänner Mynt Mina kölappar Hjälpcenter Privata meddelanden Chatt Logga ut