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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.