OPEN-SOURCE SCRIPT
Atualizado

ROC Regime Filter [HYPR-run]

557
DESCRIPTION:
A reliable universal regime filter across all assets, all timeframes. Rate of change filter that classifies price action into regime states. A suite of smoothed EMAs feeds a layered ROC engine that detects when fast momentum aligns with, or diverges from, slow structure. The filter measures; it doesn't predict. When all ROC layers stack in the same direction (parallel alignment), the trend is confirmed by arithmetic. When fast ROC diverges from slow, the regime shifts. The lag is the cost of certainty. Sweet spot is 1hr to 1D; lower timeframes get noisy.

DISCOVERING EDGE
In order to gain a persistent, mechanical edge in which trades are permitted and which are filtered out, we explored a more meaningful expression of regime classification using layered multiple ROC periods to detect when fast momentum aligns with or diverges from slow structure. This resilient regime filter has been the backbone for our automated strategies since 2021.

LAYERED ROC vs SINGLE-INDICATOR REGIME
A single RSI or ADX reading flattens the market into binary (trending/not trending). Layered ROC alignment separates six distinct states, each with different permissible trade types, so the filter matches the complexity of what the market is actually doing. Six regime states gate every decision; the combination of regime color + ROC slope is the trade filter, not either one alone. Phase transitions (green to yellow, orange to green) are the actionable signals; static states just confirm what's already happening. Webhook alerts fire on macro pivots (accumulation/distribution inflections) at the regime transition, not after the move has run.

FEATURES
- Six regime states from layered ROC alignment (see color legend below)
- Early trend detection when all layers accelerate in parallel
- ROC 200 line with regime-colored gradient fill
- Macro pivot detection: strong trend exhausting into sideways, scored by where ROC 200 sits relative to its all-time range
- Accumulation/distribution context in dashboard
- ROC 200 pivot high/low divergence markers on main chart
- Consolidation markers with conviction scoring (normal vs extreme)
- Gradient candle overlay (ROC Sticks; toggle on/off)
- Two-row dashboard: row 1 = macro context (accumulation/distribution), row 2 = current regime state with directional qualifier and slope
- Dashboard dark/light theme toggle for any chart background
- Full ROC stack in data window for manual analysis
- Webhook alerts on macro pivots (accumulation/distribution)

HOW IT WORKS
ROC alignment is the core signal. When all layers stack in the same direction, that's strong trend territory (green). When fast ROC diverges from the slower layers while slow structure still holds, the engine reclassifies from strong trend to sideways (yellow), flagging a pullback rather than trend failure. Deeper corrections where intermediate layers fall below the structural anchor fire orange, indicating a correction within the primary trend. Macro pivots fire at the inflection: strong trend exhausting into sideways for the first time. The consolidation score layers this with where ROC 200 sits in its all-time range. Consolidation at extreme ROC readings (bright green/red dots) is the highest-conviction signal for reversal.

HOW TO USE
Read the regime color, not the price. Green = strong trend long, red = strong trend short, orange = deeper correction, yellow = short pullback, white = directionless. Use regimes as a directional gate: longs during green, shorts during red. Yellow flags a pullback within trend; wait for resolution back to green/red before re-entering. Orange is a deeper correction; patience or fade with confirmation from other tools. The highest-edge signals come from regime transitions, not static states. Watch for: green breaking into yellow (macro pivot, potential reversal), extended yellow resolving back to green (continuation re-entry), and the ROC slope within a regime (slope rising in orange = trend about to resume). The data window shows the full ROC stack across all layers. When fast ROC diverges from slow, that signals continuation or reversion.

MACRO CONTEXT (Dashboard Row 1)
REGIME COLOR LEGEND (Dashboard Row 2)

snapshot

ALERTS
Macro pivot long fires when accumulation is detected (bull inflection). Macro pivot short fires when distribution is detected (bear inflection). Create alert: condition = this indicator, "Any alert() function call". Paste your webhook URL, set Open-ended, create. Alert payload is built into the script; works with any webhook receiver.

CREDITS
Advance/Decline gradient function: LucF
Notas de Lançamento
REGIME ACTION GUIDE
The regime color legend above tells you what each state means. Here is an outline mapping actions to consider versus what the indicator is showing. Watch transitions, not states. The highest-edge signals come from regime changes: green breaking into yellow (macro pivot, potential top), extended yellow resolving back to green (continuation re-entry), orange resolving into white then back to green (trend resumption). The alerts fire on these phase transitions, not on static states.

ABOVE ZERO (BULLISH STRUCTURE)
STl (green, above zero) - strong trend long, all ROC layers in parallel alignment with slope confirming. When early trend detection is enabled and all layers are also rising for 9+ bars, candles show bright green. Longs: high-probability continuation entries; trend is intact. Shorts: only high-volume spike reversions at extreme ROC 200 extension; the farther from zero, the more reliable. Transition: STl to Ssl is the macro pivot. This is the key transition; distribution or reversal may be starting.

Ssl (yellow, above zero) - pullback in uptrend. Longs: fakeout zone; reliable longs need to base first; yellow hasn't based. Shorts: mean reversion zone; when yellow rolls over (slope turning negative), shorts succeed here. STl to Ssl pivot is worth a punt; if ROC 200 is far from zero, could be a full trend reversal. Transition: Ssl resolving back to STl = continuation (pullback was just a pause). Ssl to Sml = basing deeper.

Sml (orange, above zero) - deeper correction within bullish structure. Consolidation before trend continuation. Longs: most likely resolves higher; longs set up here for the next green push. Shorts: low probability; if price made it to orange, the basing is happening and shorting into a base is fighting accumulation. Transition: Sml to STl = trend resuming, high-conviction long re-entry. Sml to white = structure weakening.

BELOW ZERO (BEARISH STRUCTURE)
STs (red, below zero) - strong trend short, all ROC layers in parallel alignment with slope confirming. Bright red candles when early trend detection is enabled and all layers falling for 9+ bars. Shorts: high-probability continuation entries. Longs: only at extreme ROC 200 extension. Transition: STs to Sss is the macro pivot; accumulation or reversal may be starting.

Sss (yellow, below zero) - pullback in downtrend. Shorts: good for continuation if it resolves back to STs, but the pivot means momentum broke. Longs: more likely a fakeout, but a quick scalp is possible; don't hold for a swing unless confirmation stacks. Transition: Sss back to STs = bearish continuation. Sss to Sms = basing deeper.

Sms (orange, below zero) - deeper correction within bearish structure. Accumulation has taken place. Longs: high conviction; any breakouts in this zone are reliable. This is where longs set up. Shorts: accumulation is happening under you; shorting into a base after the trend already corrected is fighting the tape. Transition: Sms to STs = bearish resumption (accumulation failed). Sms to white or Ssl = structure shifting bullish.

White - no regime, directionless. No edge. Wait for regime to form. White after extended orange (Sml to white or Sms to white) may signal a new regime forming; watch for the first green or red candle to break the stalemate.

ALERTS
Alerts fire on macro pivot phase transitions, not on static regime states. Macro Pivot Long (⏶) fires when the regime transitions into accumulation: strong trend exhausting into sideways with a consolidation score >= 1. "Accumulation In Play" on the dashboard means the bull macro pivot is active and price is above the pivot low. Macro Pivot Short (⏷) fires on distribution: "Distribution In Play" means the bear macro pivot is active and price is below the pivot high. Consolidation score of 2 (bright dot) means ROC 200 is at an extreme of its all-time range; highest conviction. Score of 1 (normal dot) is a standard inflection. Toggle each independently in settings.

For notifications without webhooks, create a TradingView alert with condition = this indicator, "Any alert() function call", and select push notification, email, or popup.

For webhook execution, paste your endpoint URL in the alert's Webhook URL field, set Open-ended, create. Long sends {"market":"PERPS","ticker":"...","position":"LONG",...}. Short sends the same with "position":"SHORT".

EARLY TREND DETECTION
Fires when all slow ROC layers are rising (longs) or falling (shorts) for 9+ consecutive bars while in full parallel alignment. This catches the acceleration phase before the trend is obvious on price. Toggle on/off in Display settings; when enabled, candles show brighter green/red during these windows.

MACRO PIVOT DETECTION
Fires at the inflection: strong trend exhausting into sideways for the first time. Requires N consecutive bars (default 3) of strong trend before the transition. This filters out flickering regime changes and only flags genuine trend exhaustion.

CONSOLIDATION SCORING
Layers conviction on top of macro pivots. When a pivot fires while ROC 200 is at an extreme of its all-time range, the consolidation score doubles (bright dot vs normal dot).

GRADIENT FILL
The ROC 200 line fills to zero with a transparency gradient. Deeper moves from zero = more opaque fill. Fill intensity reflects conviction, not just magnitude.

ROC STICKS (CANDLE OVERLAY)
Recolors candlesticks with the regime gradient on the main chart. Toggle on/off in Display settings.
Notas de Lançamento
Alert arrows toggle with Alerts ON/OFF and 200 ROC pivot arrows editable.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.