Skip to content
The Casebook · An idea an AI invented

Buy after volatility spike when daily range contracts

Entry at latest close if 5-day realized volatility of closes is at least 2x the 60-day realized volatility, today's range is smaller than the 3-day average range, and close is above the 5-day low. Stop 1.5 ATR below. Target 2.3 ATR above.
Why the AI thought it might work

Volatility-targeting funds cut exposure after volatility spikes and re-add as volatility decays, creating predictable buying a few days later. A stock whose 5-day realized volatility is more than twice its 60-day level but whose latest bar range is contracting signals the peak of the cutting phase and the start of re-leveraging demand.

VerdictTested Nov 22, 2026

Survivorship mirage

It clears the bar on today's winners, the stocks everyone wishes they had bought, but not on the laggards, which is where hindsight can't help.

  • It clears the bar on today's winners but not on the laggards: the winners' own rise did the work.
Trades on the laggards
1,142

42 large US stocks, 15 years

Per trade, after costs
−0.039R

Before costs +0.043R

Bar to clear
t > 2.95

By trade and by day, sized to 362 rules

What the numbers say

On the 22 laggards the rule averaged −0.039R per trade after costs over 1142 trades, against 0.184 on today's winners. Before costs the laggards were 0.043, so costs account for the sign. In bull, flat and bear markets the laggard results were −0.050, −0.043 and 0.002, so the winners' rise did the work.

How it was tested

The rule as written, coded once, run on every stock the same way.

Side
Long
Time limit
Exit at the close after 30 trading days, unless the stop, the target or its own exit comes first
Bar to clear
t > 2.95, by trade and by day, sized to the 362 rules in the search it came from
Prices
15 years of daily bars through 2026-11-20; judged 2026-11-22

The evidence

The laggards decide: 22 large stocks that lagged or fell, where hindsight can't flatter a rule. Today's winners sit beside them to show what survivorship would add.

MarketTradesPer tradet, by tradet, by dayRandom datesWinners, per trade
Bull721−0.050R−1.01−1.12 · 541d−0.054R · beats 60%+0.330R
Flat198−0.043R−0.470.29 · 113d−0.007R · beats 25%−0.160R
Bear223+0.002R0.02−0.26 · 85d+0.081R · beats 5%+0.106R
All1,142−0.039R−0.019R+0.184R

R is the result per trade in units of the risk taken (entry to stop). Costs are each stock's own trading spread (median 10.1 bps) plus 0.045R for the fills a real order wouldn't get. “By day” groups trades opened the same day, so a rule that fires on the same dates for every stock counts as a few events. “Random dates” places the same plan on random days of the same stocks in the same kind of market, 20 times; the idea must beat 95% of those draws.

The scanner we wroteShow the code
import math
from decimal import Decimal

from core.domain import Bar
from strategies.indicators import atr
from scanners.base import Candidate


class VolSpikeFadeRangeContractionLong:
    name = "vol_spike_fade_range_contraction_long"
    description = "Long after a 5d/60d realized-vol spike once the daily range contracts and price holds off the 5-day low"

    def __init__(self, short_win: int = 5, long_win: int = 60, vol_ratio_min: float = 2.0,
                 range_avg_win: int = 3, low_buffer_atr: float = 0.25,
                 stop_atr: float = 1.5, target_atr: float = 2.3, atr_period: int = 14) -> None:
        self._sw = short_win
        self._lw = long_win
        self._ratio_min = vol_ratio_min
        self._rw = range_avg_win
        self._low_buf = low_buffer_atr
        self._stop_atr = stop_atr
        self._target_atr = target_atr
        self._atr_p = atr_period

    @staticmethod
    def _rv(closes):
        rets = []
        for i in range(1, len(closes)):
            a = closes[i - 1]
            b = closes[i]
            if a <= 0 or b <= 0:
                return None
            rets.append(math.log(b / a))
        n = len(rets)
        if n < 2:
            return None
        m = sum(rets) / n
        var = sum((r - m) ** 2 for r in rets) / (n - 1)
        return math.sqrt(var)

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        need = max(self._lw + 2, self._atr_p + 2, 80)
        if len(bars) < need:
            return None
        closes = [float(b.close) for b in bars]
        rv_s = self._rv(closes[-(self._sw + 1):])
        rv_l = self._rv(closes[-(self._lw + 1):])
        if rv_s is None or rv_l is None or rv_l <= 0:
            return None
        ratio = rv_s / rv_l
        if ratio < self._ratio_min:
            return None

        cur = bars[-1]
        today_rng = float(cur.high - cur.low)
        prior = bars[-(self._rw + 1):-1]
        avg_rng = sum(float(b.high - b.low) for b in prior) / len(prior)
        if avg_rng <= 0 or today_rng >= avg_rng:
            return None

        atr_val = atr(bars, self._atr_p)
        if atr_val is None or float(atr_val) <= 0:
            return None
        atr_f = float(atr_val)

        low5 = min(float(b.low) for b in bars[-self._sw:])
        close_f = closes[-1]
        if close_f <= low5 + self._low_buf * atr_f:
            return None

        atr_dec = Decimal(str(atr_f))
        entry = cur.close
        stop = entry - Decimal(str(self._stop_atr)) * atr_dec
        target = entry + Decimal(str(self._target_atr)) * atr_dec
        if stop <= 0 or not (stop < entry < target):
            return None
        risk = entry - stop
        rr = (target - entry) / risk
        if rr < Decimal("1.5"):
            return None

        # Strength: spike magnitude, contraction depth, close location within bar
        spike_score = min(35, max(0, int((ratio - self._ratio_min) / 2.0 * 35)))
        contraction = 1.0 - today_rng / avg_rng
        contr_score = min(35, max(0, int(contraction * 70)))
        if today_rng > 0:
            close_pos = (close_f - float(cur.low)) / today_rng
        else:
            close_pos = 0.5
        close_score = min(30, max(0, int(close_pos * 30)))
        strength = max(0, min(100, spike_score + contr_score + close_score))

        thesis = (
            f"5d realized vol is {ratio:.1f}x the 60d level. Today's range is {contraction*100:.0f}% below "
            f"the {self._rw}-day average, and the close holds above the 5-day low. This suggests forced, "
            "risk-budget-driven selling is exhausting. Expect post-shock mean reversion as vol decays."
        )
        return Candidate(
            ticker=ticker,
            side="buy",
            entry=entry,
            stop=stop,
            target=target,
            risk_reward_ratio=rr.quantize(Decimal("0.01")),
            signal_strength=strength,
            thesis=thesis,
        )

Hypothetical results from our own backtest of the rule as restated, on 42 large US stocks over 15 years. Past performance, real or simulated, does not predict future results. Research and education only; not investment advice.

Have an idea of your own?

Describe it in plain words and get the same honest test in about a minute.

Run the Gauntlet
Buy after volatility spike when daily range contracts: Survivorship mirage · EdgeProven