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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。