OPEN-SOURCE SCRIPT

Explainable Quant Scorecard [TradeDots]

451
Explainable Quant Scorecard [TradeDots]

Summary

This indicator computes a composite 0 to 100 evidence score by combining seven independent normalized sub-scores: Trend, Momentum, Volatility Regime, Participation, Relative Strength, Exhaustion Risk, and Multi-Timeframe Alignment. The composite is regime-dependent: when ADX indicates a trending regime, the trend and momentum weights are boosted; when ADX indicates a range regime, the exhaustion-risk weight is boosted instead. All factor weights are exposed as inputs so the model is fully auditable and tunable. A flagship dashboard panel displays every sub-score, the composite, the active regime, and a one-line interpretation.

The intent is to give traders a transparent multi-factor reading on every bar rather than another single-indicator signal. The composite is an evidence score, not a probability or prediction.

What is original here

Composite indicators that mash several oscillators together exist in the public library. This script's contributions are:

  1. Honest factor separation. Each sub-score measures a different dimension (trend, momentum, volatility, participation, relative strength, exhaustion, multi-timeframe). Many composites silently combine correlated readings (such as two momentum oscillators) and present the result as if it were multi-factor confirmation. This script's seven factors are deliberately chosen to be diverse.
  2. Regime-dependent weighting. The composite is not a fixed weighted average. When the market is trending, trend and momentum factors carry more weight; when ranging, exhaustion-risk carries more. This addresses the well-known problem that trend-following inputs and mean-reversion inputs should not be weighted equally in all conditions.
  3. Sub-score divergence detection. The script tracks the maximum deviation of any sub-score from the composite. A large deviation triggers a "sub-score divergence" alert, warning the trader that the factors disagree even when the composite looks clean.
  4. Full transparency. All weights, all thresholds, and the regime trigger levels are user inputs. No black-box.


How it works

Each bar, seven sub-scores are computed.

1. Trend score. EMA slope over a configurable lookback, normalized to 0 to 100 via min-max over a percentile window.

2. Momentum score. Rate-of-change of close over a configurable length, min-max normalized.

3. Volatility regime score. Bollinger Bandwidth percentile mapped to a discrete numeric: compressed BBW (below the lower threshold) maps to 30, expanding BBW (above the upper threshold) maps to 70, normal BBW maps to 50. A label ("Compressed", "Normal", "Expanding") is generated alongside the numeric.

4. Participation score. Volume percentile multiplied by a close-location alignment factor. For a bullish-direction reading, a close near the bar's high earns full alignment; for a bearish-direction reading, a close near the bar's low. The result is a 0 to 100 score that rewards volume and direction-consistent closes.

5. Relative strength score. The asset's return over a configurable horizon, minus the benchmark's return over the same horizon, divided by the asset's own volatility. The result is percentile-ranked over a longer lookback (default 252 bars) to produce a 0 to 100 reading. The benchmark symbol is a user input.

6. Exhaustion risk score. Distance from the trend EMA in ATR units, mapped inversely to 0 to 100 (high exhaustion gives a low exhaustion-score, which is consistent with the convention that high scores are "good" for the composite). The dashboard inverts the label so users see "Exhaustion: High" rather than "Exhaustion: 20".

7. Multi-timeframe alignment score. The trend direction (EMA-fast vs EMA-slow) is fetched at three user-configurable higher timeframes. Each HTF's agreement with the chart-timeframe direction contributes 100, 50, or 0 to the alignment score. The final factor is the average across three timeframes.

The composite is the weighted average. When regime_weighting is enabled and ADX indicates a trending regime (above the user threshold), the trend and momentum weights are multiplied by 1.5 and the exhaustion-risk weight by 0.5. When ADX indicates a range regime (below the lower threshold), the trend and momentum weights are multiplied by 0.5 and the exhaustion-risk weight by 1.5. In a "Mixed" regime, weights are unchanged.

A four-line interpretation is assigned by composite range:

  • 75 or higher : "Constructive, multi-factor agreement"
  • 60 to 74 : "Mixed but constructive"
  • 40 to 59 : "Mixed — wait for alignment"
  • below 40 : "Bearish or unclear"


Repainting and data integrity

All sub-scores are computed on confirmed bar values. Alerts are gated by barstate.isconfirmed. The benchmark and the three multi-timeframe trend references are fetched with request.security() using prior-bar sources together with barmerge.lookahead_on — the standard non-repainting idiom that returns the last confirmed value from the requested context. These calls do not access future data.

How to read the chart

  • The composite is plotted as a line in the indicator pane, color-shifted on a red-to-green gradient based on the score.
  • Horizontal reference lines at 25, 50, and 75 demarcate bearish, midpoint, and bullish zones.
  • Sub-score plots are available but off by default to keep the pane clean. They can be enabled via input toggle.
  • The dashboard panel shows the direction in the header, then a row for each of the seven sub-scores (numeric or labelled), then a divider, then the composite score, then the interpretation line and the active regime.


Inputs

Inputs are grouped into seven sections.

  • Core Settings: trend EMA lengths and norm lookback, momentum ROC length, generic norm lookback, BB length and multiplier, ATR length, ADX length.
  • Relative Strength: benchmark symbol, RS return horizon, RS volatility length, RS percentile lookback.
  • Multi-Timeframe: three HTF inputs (default 60-minute, 240-minute, daily).
  • Factor Weights: a 0 to N weight for each of the seven sub-scores.
  • Regime Modulation: regime-weighting enable toggle, trend ADX threshold, range ADX threshold.
  • Visual Settings: dashboard toggle, panel position, panel size, panel background color, composite-plot toggle, sub-score-plot toggle.
  • Any Alert() function call conditions: per-alert toggles.


Alerts

Four alert conditions are provided:

  • Score ≥ 75 Bullish (composite at or above 75 with trend direction up)
  • Score ≥ 75 Bearish (composite at or above 75 with trend direction down)
  • Score Regime Flipped (composite crossed the 50 midpoint in either direction)
  • Sub-Score Divergence (any sub-score moves more than 30 points from the composite — a warning that factors disagree)


Each is declared via alertcondition() and fired programmatically through alert() when the corresponding input toggle is enabled, with alert.freq_once_per_bar_close. Alert messages include {{ticker}}, {{interval}}, and {{close}} placeholders.

How to use this script

  1. Read this indicator as your master "is the evidence stack constructive" check, not as an entry trigger.
  2. A composite of 75 or higher with trend direction up is the suite's highest-conviction long setup; the inverse for shorts.
  3. Read the regime cell. In a trending regime, weight your decision toward the trend and momentum sub-scores. In a range regime, weight toward exhaustion risk and relative strength.
  4. If the dashboard shows a high composite but the "Sub-Score Divergence" alert is firing, the agreement is shallow — investigate which factor disagrees before sizing up.
  5. Pair with a setup-specific indicator (sweep, breakout, zone) for entry timing. This script does not give entries.


Limitations and honest caveats

  • The composite is a weighted heuristic combination of normalized factors, not a calibrated probability. A composite of 80 does not imply an 80% probability of any outcome.
  • Regime detection uses ADX, which is lagging. The regime label will not reflect a fresh regime change on the first bar.
  • The Relative Strength benchmark is a single symbol chosen by the user. Choosing an inappropriate benchmark (for example, comparing a small-cap stock to a crypto-currency benchmark) will produce noisy RS readings.
  • The three MTF references add request.security() calls. On instruments without history at those timeframes, the MTF score may be incomplete on early bars.
  • Composite values pin to one tail when factor weights are mis-configured. The default weights are reasonable starting values; users are expected to tune for their instrument and timeframe.
  • The script makes no claim about which direction price will move; it scores the evidence stack currently visible.


Disclaimer

This script is published for informational and educational purposes. It is not investment advice and is not a recommendation to buy or sell any instrument. Composite evidence scores are descriptive, not predictive. Users are solely responsible for their own trading decisions and risk management.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน