OPEN-SOURCE SCRIPT
Percentile-Based BB% Trend - Mattes

Overview
The Percentile-Based BB% Trend is a robust momentum oscillator that reimagines the classic Bollinger %B indicator using percentile-based bands and median absolute deviation (MAD). Instead of relying on a simple moving average and standard deviation (which can be heavily influenced by outliers), this version builds dynamic bands from the 25th and 75th percentiles of price, creating a noise-resistant framework for measuring where the current price sits relative to its recent distribution.
How It’s Calculated
How It Differs From Traditional %B
Why It’s Useful
Application Examples
Great inventions require greate care!
The Percentile-Based BB% Trend is a robust momentum oscillator that reimagines the classic Bollinger %B indicator using percentile-based bands and median absolute deviation (MAD). Instead of relying on a simple moving average and standard deviation (which can be heavily influenced by outliers), this version builds dynamic bands from the 25th and 75th percentiles of price, creating a noise-resistant framework for measuring where the current price sits relative to its recent distribution.
How It’s Calculated
- Percentile Smoothing: 25th percentile (lower boundary) and 75th percentile (upper boundary) of the selected source.
- Basis Line: Midpoint between the 25th and 75th percentiles as a robust central measure.
- Robust Volatility: Median Absolute Deviation (MAD) multiplied by a user-defined factor to set band width.
- PBB% Value: (Price - Lower Band) / (Band Width), then shifted so the midline is at 0.
- Trend Line: Light EMA smoothing applied to the raw value and displayed as colored columns.
How It Differs From Traditional %B
- Uses 25th/75th percentiles + MAD instead of SMA + standard deviation → far less sensitive to outliers.
- More adaptive to real-world skewed price distributions.
- Stronger noise filtering while staying responsive to genuine momentum.
Why It’s Useful
- Reduced false signals in choppy or spiky markets
- Clear view of momentum strength and price extension
- Persistent readings above/below 0 indicate sustained bullish/bearish control
- Excellent as a trend-strength filter across all asset classes and timeframes
Application Examples
- Trend Confirmation – Midline (0) crossovers confirm direction when paired with trend-following tools.
- Overextension Warnings – Extreme readings signal potential exhaustion.
- Momentum Filtering – Avoid entries when oscillator shows weak or overstretched conditions.
- Divergence Hunting – Spot price making new highs/lows while oscillator fails to confirm.
Great inventions require greate care!
This indicator builds directly on the foundation of the Percentile-Based Bollinger Bands - Mattes, extending its robust methodology into oscillator form for deeper momentum analysis.Shoutout to all my Masterclass Brothers and L4 Gs!
Not a Standalone Strategy: This indicator is designed as a complementary tool and should always be combined with other forms of analysis (price action, volume, higher-timeframe trend, or additional indicators).Potential Lags in Explosive Moves: The robust calculations and smoothing can slightly delay signals during very strong trends.Parameter Sensitivity: Optimal length and multiplier vary by market and timeframe — backtesting is essential.No indicator guarantees profits; past performance is not indicative of future results.
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.
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.
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.