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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.