How to Detect Market Regime Shifts Before Price Moves

Written by proinvestinginvest

April 20, 2026

When the Model
Doesn’t Know —
That’s the Signal.

We built a system that detects economic cycle shifts before price confirms them. The edge isn’t in what the model predicts — it’s in the moments when it admits it has no idea.

 

The problem classic models ignore

Most risk tools measure how much the market moved. But there’s a more important question almost nobody asks: is the market moving in a way the model recognizes, or is it doing something it’s never seen before?

That difference is huge. When SPY, gold, and bonds start moving together in an unusual way, something is shifting in market structure. And that happens before price tells you anything.

That’s exactly the moment this system is built to catch.

“Markets don’t send warnings. But they leave footprints — in gold, in rates, in how equity reacts. If you know how to read them together, you get there first.”

What the model reads and why

The system works with three assets: SPY (the equity market), GLD (gold), and ^TNX (the 10-year Treasury yield). From those it builds four signals that, together, describe which phase of the cycle the market is in.

The SPY/GLD ratio is probably the most powerful signal of the four. When it rises, money is flowing into stocks — expansion. When it falls, money is seeking safety in gold — something is getting complicated. Changes in the bond yield tell you whether the Fed is tightening or easing. SPY volatility tells you if the market is nervous. And daily returns give you the momentum pulse.

How the model works under the hood

The model is intentionally simple — and that’s a strength. Instead of a black box with thousands of parameters, we use a single neuron whose logic you can explain in one sentence: it combines the four signals with weights that reflect real economic logic, and converts the result into a probability.

FIGURE 1 · NN ARCHITECTURE

The four signals enter with economically meaningful weights. High volatility (+1.5) and rising rates (+0.7) push toward a contractionary regime. A high SPY/GLD ratio (−0.9) and positive returns (−0.4) push toward expansion. The sigmoid node converts all of that into a probability between 0 and 1.

FORMULA · REGIME PROBABILITY
z(t) = −0.4·ret + 1.5·vol − 0.9·ratio + 0.7·Δrate
P(t) = 1 / (1 + e−z)
P(t) close to 1 → market in contractionary mode, risk-off
P(t) close to 0 → market in expansion, risk-on.
So far we have a regime probability. But there’s something more important: how confident is the model in that probability? That’s where Bayesian uncertainty comes in.

 

FORMULA · UNCERTAINTY Σ*(T)
Σ*(t) = rolling_std( |P(t) − smoothed_P(t)| ) + α · vol(t)
When Σ*(t) approaches 1 → the model is seeing something it’s never seen before
α = 0.06 · blends realised volatility with the model’s internal disagreement

.

What the model sees over time

P(t) isn’t a smooth line — it oscillates constantly. That’s intentional. Markets don’t sit in one regime for months at a time; they shift day by day. What we care about is when that oscillation holds above the 0.60 threshold, or when the model starts doubting itself.

FIGURE 2 · REGIME PROBABILITY P(T|X)

The orange line is the model’s output for every day in the 2019–2024 period. The dotted line marks the 0.60 threshold. The two blocks where P(t) holds above that threshold correspond to the Covid crash (Q1 2020) and the Fed rate-hike cycle (mid 2022) — the two most significant regime changes of the period.

 

When the model doesn’t know — that’s the signal

The red dots on the price chart don’t mark drawdowns — they mark the days where Σ*(t) crossed the threshold. And what’s striking is that in both major events of the period, those dots appear right at the start of the correction, not after the fact. The model detected that something was changing before price confirmed it.

FIGURE 3 · SPY PRICE + UNCERTAINTY Σ*(T)

Top panel: SPY price with Risk-Off zones shaded and red dots marking high-uncertainty events directly on the price line. Bottom panel: Σ*(t) over time. The two spikes — Q1 2020 and mid 2022 — mark the exact moments when the market entered a regime the model had never seen before.

 

The full cycle map over price

When we put the Risk-On/Risk-Off overlay directly on SPY, the picture becomes very clear. The 2019–2022 period was dominated by risk signals — not because price was falling the whole time, but because the internal market structure (vol, rates, relationship with gold) was constantly sending instability signals.

 

FIGURE 4 · SPY ADJ CLOSE · RISK-ON / RISK-OFF

Red zones show the periods when the model classified the environment as Risk-Off. The clean recovery of 2023–2024 lines up perfectly with the period when both P(t) and Σ*(t) stayed low — the model was operating on familiar ground with high conviction of expansion.

From model to portfolio: sizing by confidence

The most powerful insight from this system isn’t the regime signal — it’s how that signal translates into position size. Instead of going all-in or all-out, the model continuously adjusts exposure based on its own confidence level. When it doesn’t know, it bets less. When it knows, it bets more.

POSITION SIZING · UNCERTAINTY-SCALED
pos_size(t) = 1 / (1 + 3.0 × Σ*(t))
Σ*(t) = 0.00 → full position (100%)
Σ*(t) = 0.33 → half the capital (50%)
Σ*(t) = 1.00 → a quarter of the capital (25%)
FIGURE 5 · BACKTEST · STRATEGY VS BUY & HOLD SPY

Top panel: cumulative return of the strategy (green) vs holding SPY untouched (blue). Middle panel: how position size varies over time — it contracts exactly when uncertainty is highest. Bottom panel: Σ*(t) in sync with the other two. Period 2019–2024. Strategy Sharpe: 1.86 vs 0.81. Max drawdown: −7.2% vs −32.5%.

The system learning in real time

These animations show how the model would process new information every two trading weeks. The most interesting part is watching the red shading and uncertainty spikes appear before price drops — not as hindsight analysis, but as live signals.

    FIGURE 6 · ANIMATION · SPY PRICE WITH GROWING WINDOW

    Each frame adds 14 trading days. Watch how the Risk-Off shading covers stress periods before they’re confirmed by the final price of each period

    FIGURE 7 · ANIMATION · UNCERTAINTY Σ*(T) WITH GROWING WINDOW

    The red peaks above the 0.65 threshold are the signal that the model has entered unknown territory. Notice how after each major transition, Σ*(t) drops quickly — the model re-learns the new market structure and returns to operating with confidence.

     

    The signals in practice

     

     

    CONDITION REGIME ACTION WHY
    P(t) < 0.60 AND Σ*(t) < 0.65 Risk-On Full position Model is convinced we’re in expansion and operating on familiar ground
    P(t) > 0.60 Risk-Off Reduce 40–60% Cross-asset signals indicate the cycle is turning contractionary
    Σ*(t) > 0.65 Risk-Off Reduce 40–60% Model is in unknown territory — something is changing even if it can’t name what
    P(t) > 0.60 AND Σ*(t) > 0.65 Maximum caution 25% position Model is both convinced of stress and confused at the same time — worst case combination
    READING THE SIGNALS DAY TO DAY
    • First alert: Σ*(t) rises above 0.65 but P(t) is still below 0.60. The model is detecting that something is breaking before it can say what. Cut to half position.
    • Risk-Off confirmation: P(t) clears 0.60 and holds there for 5 consecutive days. Not noise — the cycle is turning. Adjust size based on where Σ*(t) is sitting.
    • Maximum confusion zone: P(t) oscillates rapidly around 0.50 while Σ*(t) is rising. The model doesn’t know which regime is coming. Reduce gross exposure regardless of direction.
    • Back to Risk-On: P(t) below 0.45 for 5 days and Σ*(t) declining for 10. The model is finding its footing again. Scale back up gradually.
    • Maximum conviction: P(t) < 0.35 and Σ*(t) < 0.40. The model is fully comfortable with the current regime. Full position with wide stops justified by low structural uncertainty.

    What this model can’t do

    01
    Weights are hand-coded

    The model weights reflect economic logic, not statistical optimisation. A model trained on labelled historical cycles would likely perform better out-of-sample.

    02
    Σ*(t) is an approximation

    True Bayesian uncertainty requires MC-Dropout or full variational inference. This version captures the transition signal but not the exact posterior distribution.

    03
    No precise entry timing

    The model tells you what conditions the market is in, not exactly when a reversal will happen. A high-uncertainty regime can persist for weeks before resolving.

    The best signal a model can give you isn’t what it thinks will happen. It’s when it tells you it doesn’t know — because that’s the most honest thing it can do.

    More articles

    Un clasificador neuronal entrenado sobre $GLD

    Un clasificador neuronal entrenado sobre $GLD

    Lo Que la Mayoría de los Modelos de Posicionamiento No Captura Los frameworks estándar de posicionamiento — percentiles históricos, z-score de flujos, COT neto — responden todos la misma pregunta: ¿dónde está el posicionamiento ahora?Son descriptivos. Capturan el...

    Neural network classifier trained on GLD

    Neural network classifier trained on GLD

    When the ClassifierDoesn't Know —That's the Signal. A neural network classifier trained on $GLD not only detects crowded trades — its zone of maximum uncertainty anticipates regime inflections that rolling volatility confirms too late.   What Most Positioning...

    Sequential Bayesian Regression

    Sequential Bayesian Regression

    When the Model Doesn't Know — That Is the Signal. Sequential Bayesian Regression reveals where the market is breaking from history — before volatility catches up. Most risk models measure how much markets moved. This one measures how much the model itself doesn't know...

    Stay up to date with the latest news and updates

    Master Portfolio

    You'll have access to monthly investment opportunities, daily market updates, and our investment community.

    Join our newsletter

     

    Join our newsletter

     

    Follow us

    Find information and advice on our social networks