PulseHub
OPEN-SOURCE SCRIPT

Trend Ribbon [MachineSuiteAI]

558
Trend Ribbon [MachineSuiteAI]
respect ranking, measured cross odds and auditable statistics

🟦 OVERVIEW

A five-average trend ribbon (8 / 21 / 50 / 100 / 200 by default; EMA, WMA, SMA, HMA or VWMA) built on one idea: the ribbon should measure itself.

Beyond the stack-based trend state and 50/100 cross markers, it keeps auditable statistics on the chart it is loaded on: which average price has actually been respecting (and how reliably), how every 50/100 cross resolved, what happened after squeeze expansions and after trend-health peaks — each statistic with its sample size, and each verifiable on the chart itself, dot by dot. It is built for traders who use layered moving averages and want the chart to answer two questions the ribbon genre normally leaves to folklore: which of these lines matters here, and what have these signals actually done on this symbol?

🟦 WHAT IS A TREND RIBBON?

snapshot

Moving-average ribbons are a public-domain concept: several averages of increasing length plotted together. When they are stacked in order the trend is orderly; when they compress and interleave the market is ranging; crosses of a slower pair mark regime changes. Published ribbon scripts already color stacks, count touches, score trend strength and detect squeezes.

What the genre does not do is resolve outcomes. A ribbon will mark a "golden cross" without knowing how golden crosses have actually resolved on this chart; it will call an average "support" without a record of how often that support held. This script's contribution sits one level up: measurement with discipline, and evidence you can check.

🟦 WHY THIS SCRIPT IS ORIGINAL

snapshot

- A cross odds engine. Every 50/100 cross is resolved N bars later (default 10) on the loaded symbol and timeframe: did the close move in the cross's direction? The win rate is tracked and split by volume confirmation, higher-timeframe agreement, and whipsaw-cluster membership — each split with its own sample size, greyed below a minimum. To the author's knowledge no published ribbon resolves its own crosses' outcomes, let alone per filter.
- Evidence-gated chart marks. The ✓ volume mark and ⚠ counter-HTF warning print on cross chips only where the measured split beats the chart's own base rate by a configurable margin with sufficient samples. Filters that have not helped on this chart do not decorate it.
- Auditable statistics. The respect record is drawn on the chart: numbered dots mark the counted touches of the leading average (gold = held, grey = failed) and a grey ✕ marks clean pass-throughs where nothing was tested and nothing entered the record. Every number in the panel can be verified visually — no other script found does this.
- Outcomes attached to the score and the squeeze. The 0–100 health score is not just decomposed from a stated formula — the panel reports how often the primary side was still intact at three horizons after past crossings above 80, on this chart. Squeeze expansions are likewise measured N bars later (median move, direction agreement, samples).
- Recency-weighted respect ranking. Touch counting exists in published scripts; here each average's last 12 touches form a rolling record where the newest touch weighs most, and the gold halo must be earned twice over: both the raw record and the weighted recent form have to clear a threshold. Below it the panel reads LOW RESPECT — price slicing through everything is itself information.
- Readability engineered like the statistics. Six engines share one chart only because the visual rules are strict: line identities never change (white 50, amber 100, thick grey 200 — the respect halo is an underlay beneath the leader's own line, never a recolor), whipsaw crosses are de-emphasized but never deleted so the visible ▲/▼ sequence always alternates, higher-timeframe levels identify themselves with end tags instead of a legend, and every mark on the chart has exactly one meaning. Nothing decorative, nothing unexplained.

🟦 HOW IT WORKS

snapshot

- Trend state: the 50/100 pair picks the side; the state reads BULL or BEAR only when at least 3 of the 4 adjacent stack pairs agree, otherwise CHOP. Fill opacity scales with alignment.
- Respect engine: every touch of every average runs through a small state machine on confirmed bars. A touch requires the prior close beyond the average, a penetration into a tolerance band (default 0.25 × ATR(14)) and a close back on the original side; consecutive contacts merge into one event. The touch HOLDS if no close crosses the far tolerance edge within the resolve window (default 5 bars). Each average keeps its last 12 resolved touches; the best recency-weighted hold rate (minimum 5 touches) leads the ranking, and the leader earns a soft gold halo under its own line only when raw record and recent form both clear the threshold (default 50%).
- Cross odds engine: as described above — confirmed bars only, fixed-horizon resolution, per-filter splits, evidence-gated chip marks.
- Health score: 0–100 from a stated formula — 40% stack alignment + 25% slope consistency + 20% price position + 15% width behavior. The panel tooltip decomposes the live score and reports the measured survival after 80-crossings at half, full and double the outcome window.
- MTF strip and HTF anchors: a small table shows the 50/100 cross state on five timeframes, and up to three higher-timeframe averages plot as stepped level lines (default: the 50/100/200 one regime up, with an optional corridor fill between the pair, tinted by where price trades). Both are read from the last completed bar of their timeframe with confirmed-bar indexing, so they can appear one higher-timeframe bar late but never rewrite. Anchors render only once their timeframe has a full length of history — young symbols never show statistically meaningless levels.
- Squeeze and expansion: ribbon width (widest minus narrowest core average, as % of price) is percentile-ranked over a lookback (default 250 bars); below the threshold percentile the ribbon is squeezed. Every expansion out of a squeeze is measured N bars later: median move, direction agreement with the ribbon state, and an "A-grade" slice (state agreed with the higher timeframe AND volume confirmed) tracked separately.
- Cluster damping: several crosses inside a short window classify as whipsaw; rapid re-crosses shrink to dimmed dots rather than full chips — de-emphasized, never deleted, so the visible ▲/▼ sequence always alternates. A cross suppressed into a cluster can still print later, once, if the market settles on its side.

All statistics are collected on confirmed bars only.

🟦 HOW TO USE IT

- Line identities stay fixed: white 50, amber 100, thick grey 200, fast pair in the trend color. The pair that generates the signals is always findable.
- Read the panel top-down: state, health, stack, the respected average with its raw record and recent form, cross recency, the measured win-rate splits, then width and expansion.
- A typical workflow: before treating a pullback to an average as meaningful, check that average's record — the gold halo and its numbered dots are the evidence. Before taking a cross, check whether volume or higher-timeframe agreement has historically mattered on this particular chart — the ↑ marks in the odds rows answer that. Use the MTF strip for context and the HTF corridor as the higher-timeframe decision zone.
- Defaults suit swing timeframes (4H–1D); everything is length-adjustable.

🟦 SETTINGS

- Averages: type, five core lengths, up to three optional extras, curated price source.
- Respect engine: halo and audit-dot toggles, touch tolerance, hold window, ranking window, minimum touches, gold threshold, recency decay.
- Health score: panel row toggle, outcome window.
- Cross odds engine: outcome horizon, minimum sample, evidence-mark gating mode, improvement margin.
- MTF cross strip: five timeframes, strip position.
- HTF anchors: auto or fixed anchor timeframe, three levels with lengths and colors, corridor or lines-only rendering.
- Visuals and extras: marker style (chips/dots/off), cluster damping, line-coloring mode (stack state or per-line slope), price-scale labels, squeeze shading, conviction-scaled fill, panel position, colors, volume-confirmation multiple.

🟦 ALERTS

Primary 50/100 cross (bull/bear) · fast 8/21 cross (bull/bear) · full stack aligned (bull/bear) · cross + volume (bull/bear) · squeeze start · squeeze expansion + volume · respected-average touch · respected average changed · health crossed 80 · health dropped below 40.

🟦 REPAINT & DATA NOTES

- Chips, dots and all bookkeeping wait for bar confirmation; the live bar updates until it closes.
- Higher-timeframe reads use the last completed bar of their timeframe: repaint-safe, but up to one higher-timeframe bar late by construction.
- Statistics are computed over the loaded history and reset when the chart reloads with a different amount of history; low timeframes load fewer bars.
- Volume-based features — including the VWMA average type — require a feed that supplies volume.
- PulseWire caps a script's labels at 500, so on long intraday histories the oldest cross chips drop off the left edge; the statistics still cover the full loaded history.
- MTF strip rows set below the chart's own timeframe show a dash: a lower timeframe cannot be read repaint-safely from a higher-timeframe chart.
- The higher-timeframe anchor levels can sit far from current price (a weekly 200 on a daily chart, for example), which widens the chart's auto-fitted price scale. Enable "Scale price chart only" in your chart settings — or switch anchors off — if you prefer a tight fit around price.

🟦 CREDITS

Moving averages, ribbons, MA crosses and squeeze concepts are public domain. The implementation — the respect state machine, cross odds engine, evidence gating, health decomposition with measured outcomes, repaint-safe MTF/anchor reads and the audit-dot system — was written from scratch for this script.

🟦 LIMITATIONS

- Moving averages lag; ranging markets whipsaw the state and the crosses. The cluster logic labels that condition, it does not remove it.
- All win rates, hold rates and outcome stats are historical measurements on the loaded chart only. They change with symbol, timeframe and loaded history, are greyed below the minimum sample, and do not predict future results.
- The outcome definition is direction-only over a fixed horizon — no stops, fees, or sizing; this is not a strategy backtest.

🟦 DISCLAIMER

This is an educational analysis tool, not investment advice. Historical measurements, however carefully computed, do not predict future results. Trading involves substantial risk.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.