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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.