OPEN-SOURCE SCRIPT
Nearest Percentile Moving Average Bands

While coding some filters into another indicator for Long/Short I noticed that ta.nearest.percentile might be the most useful tool in pinescript I've ever encountered.
While percentile_nearest can be used for all kind of things I decided to code moving averages from it and made bands for bottom percentage and top percentage.
The indicator will calculate the top % price of the given bar length.
Example settings:
length: 150
percentile: 99
So when using 99% it will draw a green line when price is moving above the top 1% price of the last 150 candles. It then calculates if the price is below the bottom 1% of the last 150 candles.
Trading use:
Use this indicator to check if the market is leaving normal territory. This signals a breakout move for example the dogecoin pump or the top of the range. I use this indicator to catch bull/bear moves for botting purposes. An other use would be to countertrend trade after the move has ended. With price being in top 1% for a while it is very probable that we see a large correction.
Below example of dogecoin pumps:

While percentile_nearest can be used for all kind of things I decided to code moving averages from it and made bands for bottom percentage and top percentage.
The indicator will calculate the top % price of the given bar length.
Example settings:
length: 150
percentile: 99
So when using 99% it will draw a green line when price is moving above the top 1% price of the last 150 candles. It then calculates if the price is below the bottom 1% of the last 150 candles.
Trading use:
Use this indicator to check if the market is leaving normal territory. This signals a breakout move for example the dogecoin pump or the top of the range. I use this indicator to catch bull/bear moves for botting purposes. An other use would be to countertrend trade after the move has ended. With price being in top 1% for a while it is very probable that we see a large correction.
Below example of dogecoin pumps:
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
✅ Let me help you become profitable long-term.
Patreon -> patreon.com/ChartMuse
Patreon -> patreon.com/ChartMuse
✅ Work with me:
Form -> forms.gle/caAJxCNTP4CqjFy4A
Form -> forms.gle/caAJxCNTP4CqjFy4A
Patreon -> patreon.com/ChartMuse
Patreon -> patreon.com/ChartMuse
✅ Work with me:
Form -> forms.gle/caAJxCNTP4CqjFy4A
Form -> forms.gle/caAJxCNTP4CqjFy4A
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
✅ Let me help you become profitable long-term.
Patreon -> patreon.com/ChartMuse
Patreon -> patreon.com/ChartMuse
✅ Work with me:
Form -> forms.gle/caAJxCNTP4CqjFy4A
Form -> forms.gle/caAJxCNTP4CqjFy4A
Patreon -> patreon.com/ChartMuse
Patreon -> patreon.com/ChartMuse
✅ Work with me:
Form -> forms.gle/caAJxCNTP4CqjFy4A
Form -> forms.gle/caAJxCNTP4CqjFy4A
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.