OPEN-SOURCE SCRIPT
Breadth Alpha

Breadth Alpha
A quantitative market-breadth dashboard that transforms raw breadth data into actionable, regime-aware trade signals — then validates them with a built-in backtest engine.
What It Does
1. Data Layer
Pulls the percentage of S&P 500 stocks trading above their 20 / 50 / 100 / 200-day moving averages and blends them into a single weighted composite (200d weighted 10x more than 20d) to emphasize structural trend health over short-term noise.
2. Momentum Layer
Four stacked histogram bars show the rate-of-change of the composite at four lookback horizons (default 1 / 4 / 10 / 20 bars). When all four layers agree ("4/4 confluence"), directional conviction is highest.
3. Regime Detection
The composite is classified into four regimes — Overbought, Bullish, Bearish, Oversold — using configurable thresholds (default 70 / 30). Background gradient zones and a real-time info table keep the current state visible at a glance.
4. Smart Signal Scoring
Six raw signals (OS Entry/Exit, OB Entry/Exit, Golden/Death Cross) are scored by historical edge. High-EDGE signals (e.g. OS Entry) receive double weight; negative-EDGE signals (e.g. Golden Cross) are disabled. A regime filter ensures long signals fire only in Bear/Oversold regimes and short signals only in Bull/Overbought
regimes — solving the classic "losing money in bull markets" problem of naive mean-reversion breadth strategies.
5. Backtest Analytics (10 x 16 table)
For every signal the panel reports: count, hit rate, average & median forward return, standard deviation, best/worst case, and a risk-adjusted EDGE ratio (avg / std). A regime section adds per-bar Sharpe ratios, and a confluence section quantifies the value of momentum alignment. Users can sweep the Forward Bars parameter
to study signal decay over holding periods.
How To Use It
- Look for Smart Buy/Sell markers — they only appear when score >= minimum threshold AND the regime filter passes.
- Check the Info Table (top-right) for real-time breadth values, momentum count (x/4 Up), and the current signal score (BUY/SELL x/5).
- Use the Backtest Table (bottom-left) to audit which signals actually deliver edge on your chosen symbol and timeframe. Signals with EDGE > 0.5 are statistically meaningful; negative EDGE means the signal works in reverse.
- Adjust Forward Bars (5 / 10 / 20 / 50) to find the optimal holding period where signal edge peaks before decaying.
Design Philosophy
Most breadth indicators show data. Breadth Alpha shows data, scores it, filters it by context, and proves whether it works — all inside a single Pine Script indicator with zero repainting.
A quantitative market-breadth dashboard that transforms raw breadth data into actionable, regime-aware trade signals — then validates them with a built-in backtest engine.
What It Does
1. Data Layer
Pulls the percentage of S&P 500 stocks trading above their 20 / 50 / 100 / 200-day moving averages and blends them into a single weighted composite (200d weighted 10x more than 20d) to emphasize structural trend health over short-term noise.
2. Momentum Layer
Four stacked histogram bars show the rate-of-change of the composite at four lookback horizons (default 1 / 4 / 10 / 20 bars). When all four layers agree ("4/4 confluence"), directional conviction is highest.
3. Regime Detection
The composite is classified into four regimes — Overbought, Bullish, Bearish, Oversold — using configurable thresholds (default 70 / 30). Background gradient zones and a real-time info table keep the current state visible at a glance.
4. Smart Signal Scoring
Six raw signals (OS Entry/Exit, OB Entry/Exit, Golden/Death Cross) are scored by historical edge. High-EDGE signals (e.g. OS Entry) receive double weight; negative-EDGE signals (e.g. Golden Cross) are disabled. A regime filter ensures long signals fire only in Bear/Oversold regimes and short signals only in Bull/Overbought
regimes — solving the classic "losing money in bull markets" problem of naive mean-reversion breadth strategies.
5. Backtest Analytics (10 x 16 table)
For every signal the panel reports: count, hit rate, average & median forward return, standard deviation, best/worst case, and a risk-adjusted EDGE ratio (avg / std). A regime section adds per-bar Sharpe ratios, and a confluence section quantifies the value of momentum alignment. Users can sweep the Forward Bars parameter
to study signal decay over holding periods.
How To Use It
- Look for Smart Buy/Sell markers — they only appear when score >= minimum threshold AND the regime filter passes.
- Check the Info Table (top-right) for real-time breadth values, momentum count (x/4 Up), and the current signal score (BUY/SELL x/5).
- Use the Backtest Table (bottom-left) to audit which signals actually deliver edge on your chosen symbol and timeframe. Signals with EDGE > 0.5 are statistically meaningful; negative EDGE means the signal works in reverse.
- Adjust Forward Bars (5 / 10 / 20 / 50) to find the optimal holding period where signal edge peaks before decaying.
Design Philosophy
Most breadth indicators show data. Breadth Alpha shows data, scores it, filters it by context, and proves whether it works — all inside a single Pine Script indicator with zero repainting.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.