Level 11 · Lesson 5

Regime Transitions
and Hysteresis

Every other indicator would lie to you for 5 bars. CIPHER reports truth — then gives you a three-stage warning system so you act before the flip, not after.

Scroll to begin

First — Why This Matters

Detecting a regime is half the job. Knowing it's about to end is the other half.

Lesson 11.4 taught you how CIPHER classifies every bar into TREND, RANGE, or VOLATILE. But classification alone answers only one question: what is the market doing right now?

This lesson answers a harder question: when is the market about to stop doing it? That is the question that determines whether you ride a TREND to exhaustion or exit cleanly before the transition fires. The difference in P&L between those two outcomes is significant — and it is exactly what the Regime Transition Predictor (RTP) is built to close.

The RTP gives you a three-stage warning system built on two pieces of data CIPHER collects silently on every chart: how long each regime has lasted historically, and which regime tends to follow which. When you read the guidance cell, you are reading the output of that system — a probability, not a guess.

⭐ 01 — Groundbreaking Concept

The Three-Stage Warning System — and Why Other Indicators Lie to You First

Most regime or trend indicators use N-bar hysteresis: the regime cannot change until the new state has persisted for 3, 5, or 10 bars. That lock eliminates flicker — but it also silently eliminates every early warning that lives inside those locked bars. By the time a lagged indicator confirms the transition, you have already given back 5 bars of profit. CIPHER made the opposite design choice.

CIPHER reports the raw three-score race result every bar, with no lock and no delay. Then it adds the Regime Transition Predictor on top: a probability engine that tracks how long the current regime has lasted, compares it to the 30-instance rolling average on this specific chart, and feeds the ratio into a sigmoid curve. The output is translated into three plain-English guidance states.

Watch the four-scene cycle. Scene 1: duration at 55% of average — probability ~25%, guidance reads → TREND INTACT. Run your playbook with full conviction. Scene 2: duration past average — probability climbs above 50% and the guidance cell flips to → RANGE FORMING. Amber fires. Take partials, tighten the stop. Scene 3: ratio at 1.42 × average — probability above 75%, → SHIFTING TO RANGE appears. Exit the remainder now. Scene 4: regime flips, duration resets, the clock starts again.

INTACTProb < 50%Run playbook
FORMINGProb 50–75%Tighten + partials
SHIFTINGProb > 75%Exit + switch

⭐ THE DESIGN INVERSION

Other indicators hide flicker by locking regime for N bars. CIPHER hides nothing — and gives you the probability layer instead. The guidance cell is your stability, not a lock. INTACT through flicker means the RTP is below 50%: ignore the noise. FORMING means act. SHIFTING means act now.

02 — The Hysteresis Choice

Why CIPHER doesn't wait

Hysteresis is a design shortcut. It replaces the hard problem of “how do I know if this flip is real?” with the easy answer: “wait N bars and see if it sticks.” That works for eliminating flicker, but it introduces a cost that is never acknowledged: the early warning is inside those N bars. When you confirm at bar 5, bars 1–4 were actionable information you discarded.

The left panel shows a 5-bar hysteresis approach: the regime bar changes, but the indicator does not report it for 5 bars. +5 LAG marks where the operator finally gets the signal. The right panel shows CIPHER: truth fires at bar 1 of the change. The guidance cell — not a bar lock — is what distinguishes real transitions from noise. If the guidance cell stays INTACT through the raw flicker, the RTP probability is below 50% and the flicker is noise.

WHAT HYSTERESIS COSTS YOU

On a 5-bar lock, a transition that runs for 8 bars gives you only 3 bars of the new regime before a reversal. On CIPHER with no lock, you get all 8 bars of guidance — including the FORMING warning that tells you to prepare, and the SHIFTING warning that tells you to act.

WHAT CIPHER GIVES YOU INSTEAD

A probability layer that updates every bar without lock. Below 50%: stable, run playbook. 50–75%: elevated, act early. Above 75%: imminent, act now. The stability operators need is in the probability, not in an artificial delay.

03 — INTACT · The Green Light

Regime active. Run your playbook.

INTACT (and its variants HOLDING for RANGE, CAUTIOUS for VOLATILE) appears when the RTP sigmoid probability is below 50%. The current regime has not yet reached its historical average duration on this chart. The three-score race still produces a clear winner with no elevated transition signal. This is the window for full-conviction execution.

Watch the duration counter climb. As long as it stays below the historical average (35 bars in this example), probability stays well below 50% and the guidance cell holds on → TREND INTACT. The probability bar does not reach the FORMING threshold. This is not complacency — it is calibrated confidence backed by the instrument's own history.

INTACT VARIANTS BY REGIME

→ TREND INTACT when current regime is TREND and prob < 50%. → RANGE HOLDING when regime is RANGE and prob < 50%. → STAY CAUTIOUS is VOLATILE's stable label — it always carries a warning tone because VOLATILE itself demands caution.

OPERATOR RULE

During INTACT: run your regime's playbook at full sizing. Add size on valid setups. Do not second-guess the regime. The probability is telling you the transition is not due.

INTACT THROUGH FLICKER

If the raw regime cell (col 2) flickers bar-to-bar while the guidance cell holds on INTACT, the RTP is below 50% — that flicker is just a near-tie in the three-score race, not a real transition. The guidance cell is ground truth. Ignore the raw flicker.

04 — FORMING · The Amber Light

Probability elevated. Tighten and prepare.

FORMING fires when rtp_change_prob > 50 (Pine line 3351). The regime is still active — cell 2 still reads TREND, RANGE, or VOLATILE — but the sigmoid has crossed its midpoint. The current regime has run longer than roughly half of all historical durations on this chart. A transition is now more likely than not in the near term.

The animation mirrors your actual screenshot: TREND in cell 2, → RANGE FORMING in amber in cell 3. Duration is at 42 bars against a 30-bar average on the Ribbon row — both rows showing the same aging signal simultaneously. Watch the probability bar fill into the 50–75% amber zone as duration climbs, inching toward the SHIFTING threshold at 75%.

THE FORMING PLAYBOOK

Step 1: Take 30–50% partial profits on existing positions in the current regime. Step 2: Tighten trailing stop on the remainder to lock in gains. Step 3: Do not add new full-size positions in the current regime. Step 4: Watch the guidance cell for escalation to SHIFTING.

WHAT FORMING IS NOT

FORMING is not a confirmed transition. Regime cell 2 still shows the current regime. FORMING is a probability elevation — the transition is likely, not certain. Some FORMING states resolve back to INTACT if the market re-energises the current regime. The SHIFTING label (75%+) is the confirmed-imminent signal.

05 — SHIFTING · The Red Light

Transition imminent. Exit and switch playbook.

SHIFTING fires when rtp_change_prob > 75 (Pine line 3352). The guidance cell switches from → X FORMING to → SHIFTING TO X, still in amber. The regime cell (col 2) still shows the current regime — the flip has not yet happened — but the sigmoid is telling you it is statistically imminent. This is your last clean exit window before the market changes character.

Scene 1 shows SHIFTING active: regime cell still reads TREND, guidance reads → SHIFTING TO RANGE with glow. The probability bar is above 75%. Scene 2 shows the transition that follows: the clock resets to bar 1, probability drops to ~5%, and the RANGE playbook begins. The entire SHIFTING window — the time between guidance firing and the actual flip — is your operator advantage. Use it.

THE SHIFTING PLAYBOOK

Step 1: Exit the full remaining position in the current regime. Do not wait for cell 2 to flip — that confirmation costs you the best price. Step 2: Cancel any pending orders aligned with the current regime. Step 3: Identify the most likely next regime from the guidance text (SHIFTING TO RANGE / SHIFTING TO TREND / SHIFTING TO VOLATILE) and prepare those setups. Step 4: Wait for the flip and the new regime's INTACT confirmation before entering.

SHIFTING DOES NOT PREDICT DIRECTION

SHIFTING TO RANGE after a TREND does not mean price will reverse. RANGE is directionless — it means the trend energy is exhausting. Price may consolidate sideways, retrace partially, or oscillate. The regime label predicts market character, not price direction.

BOTH FORMING AND SHIFTING ARE AMBER

Pine line 3354 sets both FORMING and SHIFTING guidance to AMBER color regardless of which regime is predicted. The distinction between them is the text — FORMING vs. SHIFTING — not the color. Read the words, not just the color.

06 — The Sigmoid Engine

How duration becomes probability

The probability of regime change is not linear with duration. CIPHER uses a sigmoid (logistic) curve centered at a ratio of 1.0 — meaning when the current regime has lasted exactly as long as its historical average, the sigmoid outputs approximately 60%. This is a deliberately early trigger: the FORMING threshold at 50% is crossed before the regime reaches its average.

Watch the marker sweep from left to right. The curve is lazy early: at 50% of the historical average (ratio 0.5), probability is only ~25% — no warning fires. The sigmoid rises steeply through the 1.0× region. At ratio 1.42×, probability is ~82% and SHIFTING fires. The curve caps at 95% to prevent false certainty — no regime ever shows 100% probability of ending, because history always admits exceptions.

THE PINE FORMULA (LINE 574)

rtp_ratio = rtp_duration / rtp_avg_dur
rtp_change_prob = min(95, max(5,
  100 / (1 + exp(−3.5 × (rtp_ratio − 1.0))))
)

The −3.5 steepness factor controls how quickly the curve rises through the 1.0 inflection point. Steeper = faster escalation from INTACT to FORMING to SHIFTING. The chosen value gives approximately a 0.4× ratio spread between the 50% and 75% thresholds.

WHY SIGMOID AND NOT LINEAR

A linear probability would flag FORMING too early (at ratio 0.5, linear = 50%) and would hit 100% before the regime actually ends. The sigmoid's S-shape matches how regime exhaustion actually behaves: slow accumulation of risk early, rapid escalation once past the average, then asymptotic as the regime extends extremely far.

07 — The Rolling Duration Arrays

How CIPHER learns your chart

Every time a regime ends, CIPHER records how long it lasted by pushing that duration into a rolling array for that regime type. There are three arrays: dur_trend, dur_range, and dur_volatile. Each holds a maximum of 30 completed durations. The historical average used by the sigmoid — the denominator in the ratio — is array.avg() over whatever is currently stored.

Watch the array fill slot by slot. Each cell shows a completed TREND duration. The average updates on every push. When the array reaches 30 entries, the next push calls array.shift() to remove the oldest value before adding the new one — the array stays at 30, always weighted toward recent behavior. This is how CIPHER self-calibrates: a chart that develops a new regime character over time will gradually shift its average to reflect the new normal.

THE PINE IMPLEMENTATION (LINES 520–551)

var array<int> dur_trend = array.new_int(0)
— on regime change: array.push(dur_trend, prev_dur)
— if array.size(dur_trend) > 30: array.shift(dur_trend)
— rtp_avg_dur = array.avg(dur_trend)

EARLY-SESSION BEHAVIOR

When CIPHER is first loaded on a chart, the arrays are empty and rtp_avg_dur = na. The RTP guidance defaults to the stable state (INTACT / HOLDING / CAUTIOUS) until enough history accumulates. On an active instrument, meaningful averages typically emerge after 5–10 completed regime cycles. Do not read transition warnings on a freshly loaded chart until the arrays have data.

08 — The Transition Matrix

Six paths. One most likely.

Alongside the duration arrays, CIPHER maintains six integer counters — one for each possible transition between the three regimes. Every time a regime flip occurs, the matching counter increments. The six paths are: T→R, T→V, R→T, R→V, V→T, V→R. (A regime does not transition to itself, so there are no T→T, R→R, or V→V counters.)

Three chart scenarios cycle. In each, the matrix counters are populated by historical flips. When the current regime is highlighted, the most likely next regime is simply the destination with the higher counter from the current regime's row. It is a plain integer comparison — no percentages, no weighting. The chart that trends into range most often (EURUSD 1H, scenario 1) produces a dominant T→R path. The chart with frequent volatility spikes (GBPUSD 5m, scenario 2) produces a dominant T→V path.

THE PINE IMPLEMENTATION (LINES 524–565)

var int tr_trend_range = 0   // T→R
var int tr_trend_volatile = 0 // T→V
— on regime change from TREND to RANGE: tr_trend_range += 1
— rtp_next = tr_trend_range >= tr_trend_volatile ? "RANGE" : "VOLATILE"

WHAT THE MATRIX CANNOT DO

The matrix predicts the most likely next regime type, not the magnitude of the move or how long the next regime will last. A T→R transition could be a 5-bar consolidation or a 50-bar range. Use the matrix for playbook preparation, not for position sizing on the new regime.

09 — Timeframe Character

Why your 1H and 15m have different choreography

The transition matrix and duration arrays are learned independently per chart. Load CIPHER on EURUSD 1H and EURUSD 15m simultaneously and you will get two different matrices, two different average durations, and two different “most likely next” outputs. This is not a bug — it is the RTP correctly capturing that regime physics change with timeframe.

The 1H matrix (left) shows TREND→RANGE at 73% — on this timeframe, sustained trends exhaust into consolidation. Average TREND duration is 38 bars. The 15m matrix (right) shows TREND→VOLATILE at 62% — on this timeframe, economic releases and spread events regularly spike ATR during trending moves. Average TREND duration is only 18 bars. The same instrument, opposite dominant transition paths. Use the matrix from the timeframe you are executing on.

PRACTICAL IMPLICATION

If you use the 1H for bias and the 15m for entry, check both matrices. The 1H FORMING signal tells you the bigger-picture trend is aging. The 15m matrix tells you whether the flip will likely land in RANGE (consolidation entry opportunity) or VOLATILE (stay flat). These two pieces of information together inform both exit timing and re-entry setup.

WHEN THE MATRIX IS SPARSE

On a fresh chart load, the counters start at zero. If only one transition type has fired (e.g., two T→R with zero T→V), the matrix will show RANGE as most likely — but this is based on only two data points. The matrix becomes reliable after roughly 10–15 completed transitions per from-regime row. On a freshly loaded chart, treat the “most likely next” output as provisional until history builds.

10 — The Operator's FORMING Playbook

What to do at 50–75% probability

FORMING is the window between knowing something is likely and knowing it is imminent. That window is an advantage — it is time to act before the market forces your hand. The three-step FORMING playbook is not about fear; it is about locking in what you have earned while the regime is still running in your favor.

Watch the three-step sequence. Step 1: FORMING fires, position is still full, guidance turns amber. Step 2: 40% partial exit taken at market — profit locked on that portion regardless of what happens next. Step 3: trailing stop moves up to 52% of the price run — the remaining 60% is now protected against a reversal that returns to the halfway point. When SHIFTING fires, the remainder exits from a position of strength.

THE FOUR FORMING RULES

Rule 1: Take 30–50% partial at market immediately on FORMING — not on the next bar, not when it “looks like it's topping”. The signal is the trigger. Rule 2: Tighten trailing stop to no more than 50% of the current profit run. Rule 3: Do not open new full-size positions in the current regime while FORMING is active. Rule 4: Watch the guidance cell, not the price action, for the SHIFTING escalation.

WHAT IF FORMING RESOLVES BACK TO INTACT?

Some FORMING states do not escalate. The regime re-energises (ADX spikes higher, ATR backs off) and the probability drops back below 50%. In that case: the partial you took is still good — it was a correct risk management action with the information available. The remaining position continues with the tighter stop. This is the right outcome of a probabilistic system, not an error.

11 — The Operator's SHIFTING Playbook

When 75%+ fires — act before the flip

SHIFTING is the operator's last clean exit window. The regime has not yet flipped — cell 2 still shows the current regime — but the sigmoid has crossed 75%. Waiting for cell 2 to confirm the flip is a strategy that costs you the best exit price. The operator who acts on SHIFTING exits into liquidity; the operator who waits exits into a market that has already changed character.

Four steps cycle: FORMING with partial done (position at 60%), SHIFTING fires (full exit executed immediately, do not wait for cell 2 to flip), transition confirmed (flat, clock resets), and new regime INTACT (RANGE playbook preparation begins). The most critical step is step 2: exit on SHIFTING, not on the confirmed flip. Every bar of delay between SHIFTING and your exit is a bar of increasing risk.

THE CRITICAL DISTINCTION

SHIFTING TO RANGE does not mean price drops. RANGE is a directionless regime. The trend energy is exhausting. Price may consolidate sideways, retrace partially, or begin a slow oscillation. Do not reverse short on a SHIFTING signal — wait for the RANGE INTACT confirmation and look for range-fading setups from there.

RE-ENTRY DISCIPLINE

After a transition, wait for the new regime to show INTACT or HOLDING guidance before entering new positions. SHIFTING from the prior regime + HOLDING on the new regime = confirmed transition. Entering during SHIFTING of the new regime before it has established its character is premature.

12 — VOLATILE Transition Special Cases

The regime that breaks the pattern

VOLATILE has the shortest average regime duration of the three — typically 5–15 bars on most instruments and timeframes. This means the RTP sigmoid escalates from INTACT to SHIFTING much faster during VOLATILE than during TREND or RANGE. When VOLATILE fires, you often have only a few bars before FORMING appears and only a few more before SHIFTING fires. The pace is different.

Two VOLATILE transition paths. V→TREND: the ATR spike resolves into a sustained directional move — the volatility was the birth of a new trend. V→RANGE: the spike fades and price returns to oscillation — the volatility was a news event that had no follow-through. Both are common. The transition matrix tells you which path this specific instrument on this specific timeframe takes more often.

OPERATOR RULE DURING VOLATILE

The moment VOLATILE fires: reduce size, widen mental stops, and watch the transition matrix to know which follow-on regime is statistically more likely. Do not run the TREND or RANGE playbook through VOLATILE. Do not fade the spike. When VOLATILE SHIFTING fires, the incoming regime is known from the matrix — prepare that playbook while the transition completes.

VOLATILE DOES NOT COUNT IN INTACT

The VOLATILE guidance's stable state is → STAY CAUTIOUS — not INTACT or HOLDING. The word choice is deliberate: VOLATILE is never a regime you run aggressively. Even at low probability, the regime demands caution. STAY CAUTIOUS is the minimum posture, not a green light.

13 — Transition in the Full Command Center Context

RTP in context — when multiple rows go amber together

The Regime row does not operate in isolation. When a FORMING or SHIFTING signal fires, it coincides with other Command Center rows reaching similar conclusions through their own engines. The header action cell, Ribbon aging, Momentum fading, and Last Signal aging all independently converge on the same warning. When multiple rows shift to amber simultaneously, the regime guidance is not a lone signal — it is part of a multi-system convergence.

Watch the Command Center flip between INTACT and FORMING states. During INTACT, all rows read in teal — header, Ribbon, Momentum, Regime, Last Signal are aligned. When FORMING fires on the Regime row, notice the simultaneous amber shift across Ribbon (→ AGING 42b, avg 30), Momentum (→ REDUCE SIZE), header (→ TREND AGING), and Last Signal (→ AGING). This is the exact pattern visible in your screenshot. The multiple amber rows are independent corroboration, not redundancy.

OPERATOR CONFIDENCE LADDER

One row in amber = elevated probability from one engine. Two rows in amber = two independent engines agreeing. Three or more rows in amber = high-confidence transition signal. When Regime shows FORMING and Ribbon shows AGING and Momentum shows REDUCE SIZE, the partial exit on FORMING is not a timid move — it is a high-confidence operator action backed by three converging systems.

14 — Six Common Mistakes

The Transition Timing Operator's error log

These are the six errors that operators make when reading regime transitions. Each one has a concrete cost. Knowing the mistake in advance is half the fix.

MISTAKE 01Ignoring FORMING because regime cell still says TREND

The guidance cell is the forecaster. Cell 2 shows what the market IS doing. Cell 3 shows what it is about to do. Ignoring cell 3 because cell 2 looks fine is reading only half the row.

MISTAKE 02Waiting for cell 2 to confirm before acting on SHIFTING

By the time regime cell 2 flips to the new regime, SHIFTING has already fired one or more bars ago. Waiting for confirmation means exiting into a market that has already changed character, at a worse price.

MISTAKE 03Trading on raw regime flicker instead of guidance

When raw regime flickers bar-to-bar but guidance holds INTACT, the RTP probability is below 50%. The flicker is near-tie noise. Switching playbooks on individual flicker bars produces whipsaw losses.

MISTAKE 04Treating VOLATILE as negligible because it is rare

VOLATILE is the highest-risk regime precisely because it is infrequent. When it fires, the ATR spike has crossed 1.5× its 50-bar average. This is a genuine dislocation event, not a temporary blip. Running any standard playbook through VOLATILE is a capital risk.

MISTAKE 05Adding size at FORMING instead of reducing

FORMING means the regime is statistically aging — past 50% of its historical average duration. Adding size when the regime is probabilistically late in its lifecycle is the inverse of correct risk management. INTACT is the window for adding; FORMING is the window for reducing.

MISTAKE 06Reading the transition matrix on a freshly loaded chart

The six transition counters start at zero on every fresh chart load. A matrix with only 2–3 recorded transitions gives statistically meaningless “most likely next” outputs. Trust the matrix only after 10+ completed transitions per from-regime row.

15 — Cheat Sheet

Transition Timing Operator reference

THREE-STAGE GUIDANCE STATES

INTACT / HOLDING / CAUTIOUS — prob < 50%. Regime stable. Run playbook at full conviction.

X FORMING — prob 50–75%. Regime aging. Take 30–50% partials, tighten stop, watch for SHIFTING.

SHIFTING TO X — prob > 75%. Transition imminent. Exit full remainder. Switch playbook preparation.

SIGMOID CALIBRATION (Pine line 574)

ratio = duration ÷ avg_duration

prob = min(95, max(5, 100 / (1 + exp(−3.5 × (ratio − 1.0)))))

ratio 0.5× → ~25%    ratio 1.0× → ~60%    ratio 1.4× → ~82%

ROLLING ARRAYS

Three arrays: dur_trend, dur_range, dur_volatile

Max 30 entries each — array.push on regime end, array.shift on overflow

rtp_avg_dur = array.avg() — na when empty (early session)

TRANSITION MATRIX

Six integer counters: T→R, T→V, R→T, R→V, V→T, V→R

Most likely next = higher counter in current regime's row (simple comparison)

Reliable after ~10–15 transitions per from-regime row

COLORS (Pine line 3354)

Teal — TREND INTACT guidance    Amber — FORMING, SHIFTING, RANGE HOLDING    Magenta — VOLATILE regime label only

Both FORMING and SHIFTING use amber regardless of predicted next regime. Read the text, not just the color.

TIMEFRAME INDEPENDENCE

Each timeframe has its own arrays, matrix, and averages. 1H and 15m on the same instrument will produce different matrices and different FORMING thresholds. Use the matrix from your execution timeframe.

16 — Scenario Game

Time the Transition Like an Operator

Five scenarios. Each puts you in a live-feeling transition-timing situation. Pick the right operator response — explanations appear after every answer, including for wrong answers.

Round 1 of 5

Score: 0/5

You are long EURUSD 1H. The Command Center Regime row reads: Regime | TREND | → RANGE FORMING. The chart still looks bullish. Your position is up 1.2R and your stop is at breakeven.

What is the correct operator response to FORMING at this moment?

17 — Knowledge Check

Final Quiz — 8 Questions

Question 1 of 8

At what RTP probability threshold does the guidance cell flip from INTACT/HOLDING to X FORMING?

Question 2 of 8

The sigmoid formula used by the RTP is sigmoid(−3.5 × (ratio − 1.0)). At ratio = 1.0 (duration exactly at historical average), what probability does the sigmoid output?

Question 3 of 8

How many duration values does the RTP store per regime type in its rolling history arrays?

Question 4 of 8

The transition matrix tracks six transition paths. If the current regime is RANGE and the matrix shows tr_range_trend = 14 and tr_range_volatile = 6, what does the RTP output as "most likely next"?

Question 5 of 8

The guidance cell reads "→ SHIFTING TO RANGE" while the regime cell (col 2) still reads TREND. What color does the guidance cell render in?

Question 6 of 8

Why does CIPHER use no N-bar hysteresis for regime classification?

Question 7 of 8

Two charts of the same instrument on different timeframes produce different transition matrices. Which statement is correct?

Question 8 of 8

The FORMING guidance fires when RTP probability is 50–75%. What is the correct operator response during FORMING?

← Back to Academy