OPEN-SOURCE SCRIPT
Ribbon Concordance [RC Tools]

RC Tools — Ribbon Concordance
─────────────────────────────────────────────────────────────
█ OVERVIEW
Most ribbon-of-moving-averages tools either average the ribbon or rely on simple crossovers. This one asks a different question: is the ribbon consistently ORDERED? A cleanly stacked ribbon signals real trend conviction; a tangled, crossing one signals chop — often before any single moving average has crossed another.
█ WHAT IT DOES
Plots a live moving-average ribbon directly on the price chart (choice of 7 MA types, up to 10 MAs), plus a rank-concordance score (-100 to +100) in its own pane. Classifies the ribbon into four bands — Strong Bullish, Weak Bullish, Weak Bearish, Strong Bearish — colours the chart background accordingly, and shows a table with the current band, how long price has been in it, and historical base rates (average forward return and win rate) for each band.
█ THE THEORY BEHIND IT
Ribbon tools usually throw away information about HOW consistently the ribbon is stacked, collapsing it to an average or a single crossover event. This tool instead measures rank concordance — a public, long-established statistical concept (related to Kendall's tau) that quantifies how well two orderings agree with each other. Applied to a moving-average ribbon: compare every pair of MAs, shorter-period against longer-period, and score whether their relative ordering is consistent with a clean trend. A ribbon where every shorter MA sits above every longer one (or below, for a downtrend) scores near the extreme; a tangled, crossing ribbon averages out near zero. This is a different statistical question than "is price above its moving average" or "how efficient was the recent price path" (see the Regime Classifier for that approach) — it is specifically about internal agreement across the whole ribbon at once.
█ HOW IT IS CALCULATED
1. Build a ribbon of N moving averages (configurable type and count), with periods increasing linearly from a base period by a fixed spacing.
2. For every pair of MAs (i, j) where i has a shorter period than j: score +1 if MA > MA[j] (bullish-consistent ordering), -1 if reversed, 0 if tied.
3. Sum all pair scores and normalise by the number of pairs compared, scaled to -100..+100.
4. Optionally EMA-smooth the raw score, which is otherwise a somewhat steppy pairwise count, for a cleaner read.
Classification occurs ONLY on confirmed bar close — the band never flips mid-bar and reverses. The MA ribbon itself plots live, exactly like any moving average on any chart; that is normal behaviour, not repainting. Only the concordance score and its band classification are held to confirmed bars.
█ SETTINGS & CONFIGURATION
• Source, MA Type (SMA / EMA / WMA / RMA / HMA / DEMA / TEMA)
• Base Period and Period Spacing — set the shortest MA and the gap between each successive one
• Ribbon Size (3-10 MAs) — more MAs smooth the read but add lag from the longest one; fewer react faster but are noisier
• Score Smoothing Length — EMA smoothing on the raw concordance score (set to 1 for none)
• Strong Threshold — the score above which (or below its negative) a band counts as "Strong" rather than "Weak"
• Forward Return Window — the horizon used for the base-rate table
• Show MA Ribbon on Chart — toggle the ribbon overlay off if you only want the concordance pane
• Ribbon gradient colours (short end / long end) and band colours are fully configurable
█ HOW TO USE IT
Use it as a trend-conviction filter alongside your existing process. Strong Bullish/Bearish bands indicate a cleanly stacked ribbon — a higher-conviction environment for trend-following approaches. Weak bands, or frequent flips between Weak Bullish and Weak Bearish, indicate the ribbon is loosely ordered — more caution warranted for trend-following, and potentially a more favourable environment for mean-reversion approaches instead. Check the base-rate table's sample count before assuming any one band is systematically favourable.
Works on any asset and timeframe; ribbon size and spacing should be tuned to the timeframe you trade (a wide, long-spaced ribbon on a low timeframe will lag heavily).
█ LIMITATIONS
• This is a ribbon of moving averages — inherently lagging by construction. It confirms alignment after price has already moved, and this cannot be removed without curve-fitting.
• Near-zero or Weak readings are common in choppy, range-bound conditions and do NOT predict a breakout direction — they only describe the ribbon's current state of (dis)agreement.
• Ribbon size is a real trade-off: more MAs smooth the read but add lag from the longest included MA; fewer MAs react faster but are noisier.
• The concordance score and band update on confirmed bar close only. The ribbon MA lines themselves plot live, like any moving average — that is normal behaviour, not repainting.
• Historical base-rate stats need a meaningful sample count (check N) before being trusted, especially for less common bands.
• Four bands are a deliberate simplification of a continuous reality. Markets do not actually occupy discrete states.
█ DISCLAIMER
For educational and informational purposes only. Nothing here is financial advice. Past behaviour of any band does not indicate future results. Trade at your own risk.
─────────────────────────────────────────────────────────────
█ OVERVIEW
Most ribbon-of-moving-averages tools either average the ribbon or rely on simple crossovers. This one asks a different question: is the ribbon consistently ORDERED? A cleanly stacked ribbon signals real trend conviction; a tangled, crossing one signals chop — often before any single moving average has crossed another.
█ WHAT IT DOES
Plots a live moving-average ribbon directly on the price chart (choice of 7 MA types, up to 10 MAs), plus a rank-concordance score (-100 to +100) in its own pane. Classifies the ribbon into four bands — Strong Bullish, Weak Bullish, Weak Bearish, Strong Bearish — colours the chart background accordingly, and shows a table with the current band, how long price has been in it, and historical base rates (average forward return and win rate) for each band.
█ THE THEORY BEHIND IT
Ribbon tools usually throw away information about HOW consistently the ribbon is stacked, collapsing it to an average or a single crossover event. This tool instead measures rank concordance — a public, long-established statistical concept (related to Kendall's tau) that quantifies how well two orderings agree with each other. Applied to a moving-average ribbon: compare every pair of MAs, shorter-period against longer-period, and score whether their relative ordering is consistent with a clean trend. A ribbon where every shorter MA sits above every longer one (or below, for a downtrend) scores near the extreme; a tangled, crossing ribbon averages out near zero. This is a different statistical question than "is price above its moving average" or "how efficient was the recent price path" (see the Regime Classifier for that approach) — it is specifically about internal agreement across the whole ribbon at once.
█ HOW IT IS CALCULATED
1. Build a ribbon of N moving averages (configurable type and count), with periods increasing linearly from a base period by a fixed spacing.
2. For every pair of MAs (i, j) where i has a shorter period than j: score +1 if MA > MA[j] (bullish-consistent ordering), -1 if reversed, 0 if tied.
3. Sum all pair scores and normalise by the number of pairs compared, scaled to -100..+100.
4. Optionally EMA-smooth the raw score, which is otherwise a somewhat steppy pairwise count, for a cleaner read.
Classification occurs ONLY on confirmed bar close — the band never flips mid-bar and reverses. The MA ribbon itself plots live, exactly like any moving average on any chart; that is normal behaviour, not repainting. Only the concordance score and its band classification are held to confirmed bars.
█ SETTINGS & CONFIGURATION
• Source, MA Type (SMA / EMA / WMA / RMA / HMA / DEMA / TEMA)
• Base Period and Period Spacing — set the shortest MA and the gap between each successive one
• Ribbon Size (3-10 MAs) — more MAs smooth the read but add lag from the longest one; fewer react faster but are noisier
• Score Smoothing Length — EMA smoothing on the raw concordance score (set to 1 for none)
• Strong Threshold — the score above which (or below its negative) a band counts as "Strong" rather than "Weak"
• Forward Return Window — the horizon used for the base-rate table
• Show MA Ribbon on Chart — toggle the ribbon overlay off if you only want the concordance pane
• Ribbon gradient colours (short end / long end) and band colours are fully configurable
█ HOW TO USE IT
Use it as a trend-conviction filter alongside your existing process. Strong Bullish/Bearish bands indicate a cleanly stacked ribbon — a higher-conviction environment for trend-following approaches. Weak bands, or frequent flips between Weak Bullish and Weak Bearish, indicate the ribbon is loosely ordered — more caution warranted for trend-following, and potentially a more favourable environment for mean-reversion approaches instead. Check the base-rate table's sample count before assuming any one band is systematically favourable.
Works on any asset and timeframe; ribbon size and spacing should be tuned to the timeframe you trade (a wide, long-spaced ribbon on a low timeframe will lag heavily).
█ LIMITATIONS
• This is a ribbon of moving averages — inherently lagging by construction. It confirms alignment after price has already moved, and this cannot be removed without curve-fitting.
• Near-zero or Weak readings are common in choppy, range-bound conditions and do NOT predict a breakout direction — they only describe the ribbon's current state of (dis)agreement.
• Ribbon size is a real trade-off: more MAs smooth the read but add lag from the longest included MA; fewer MAs react faster but are noisier.
• The concordance score and band update on confirmed bar close only. The ribbon MA lines themselves plot live, like any moving average — that is normal behaviour, not repainting.
• Historical base-rate stats need a meaningful sample count (check N) before being trusted, especially for less common bands.
• Four bands are a deliberate simplification of a continuous reality. Markets do not actually occupy discrete states.
█ DISCLAIMER
For educational and informational purposes only. Nothing here is financial advice. Past behaviour of any band does not indicate future results. Trade at your own risk.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.