Skip to content
The Casebook · An idea an AI invented

Short failed rally below 50% retracement of 15-bar range

Identify the high and low of the last 15 bars. Today's close is below the 50% retracement level of the 15-bar range, but the high in the last 3 bars touched at least 40% of the range retracement from the low, and close is below 20-day SMA and today's close < open. Short at close. Stop = max high of last 3 bars plus 0.2*ATR(14). Target = low of the 15-bar range minus 0.5*ATR(14).
Why the AI thought it might work

In downtrends, rallies that fail to reclaim the midpoint of a prior selloff leg show sellers defending supply from trapped buyers; stop-loss and margin-driven supply accumulates at those levels, producing continuation. This is a supply-zone effect from trapped holders rather than a pattern.

VerdictTested Nov 22, 2026

Loses money

After costs it lost money on the stocks that decide the verdict.

  • −0.175R a trade after costs on the laggard stocks.
Trades on the laggards
2,104

42 large US stocks, 15 years

Per trade, after costs
−0.175R

Before costs −0.032R

Bar to clear
t > 2.95

By trade and by day, sized to 362 rules

What the numbers say

On the laggard stocks the idea averaged −0.175R per trade after costs over 2104 trades, against −0.032R before costs. The winners did worse at −0.236R. Each market type was negative: −0.119R in bull, −0.179R in flat and −0.47R in bear, where it beat only 5% of random-date draws. The loss in every setting is why the verdict is loses money.

How it was tested

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

Side
Short
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
Bull1,460−0.119R−2.62−2.23 · 965d−0.181R · beats 95%−0.270R
Flat376−0.179R−2.16−1.75 · 236d−0.218R · beats 70%−0.015R
Bear268−0.470R−5.73−4.77 · 130d−0.237R · beats 5%−0.440R
All2,104−0.175R−0.195R−0.236R

R is the result per trade in units of the risk taken (entry to stop). Costs are each stock's own trading spread (median 11.4 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
from decimal import Decimal

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


class TenDayRangeMidpointFailureShort:
    name = "ten_day_range_midpoint_failure_short"
    description = "Short a red close back below the 50% midpoint of a 15-bar selloff leg after a rally touched the 40% retracement, below the 20-SMA"

    def __init__(self, range_len: int = 15, rally_len: int = 3, min_retrace: float = 0.4,
                 mid_level: float = 0.5, sma_len: int = 20, atr_len: int = 14,
                 stop_atr: float = 0.2, target_atr: float = 0.5, min_rr: float = 1.5,
                 min_bars: int = 60) -> None:
        self._range_len = range_len
        self._rally_len = rally_len
        self._min_retrace = Decimal(str(min_retrace))
        self._mid_level = Decimal(str(mid_level))
        self._sma_len = sma_len
        self._atr_len = atr_len
        self._stop_atr = Decimal(str(stop_atr))
        self._target_atr = Decimal(str(target_atr))
        self._min_rr = Decimal(str(min_rr))
        self._min_bars = max(min_bars, range_len + sma_len + 5)

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        n = len(bars)
        if n < self._min_bars:
            return None
        window = bars[-self._range_len:]
        cur = bars[-1]

        hi_idx = 0
        lo_idx = 0
        for i, b in enumerate(window):
            if b.high > window[hi_idx].high:
                hi_idx = i
            if b.low < window[lo_idx].low:
                lo_idx = i
        range_high = window[hi_idx].high
        range_low = window[lo_idx].low
        rng = range_high - range_low
        if rng <= 0:
            return None

        start = self._range_len - self._rally_len
        rally_idx = start
        for i in range(start, self._range_len):
            if window[i].high > window[rally_idx].high:
                rally_idx = i
        rally_high = window[rally_idx].high

        # Selloff leg: high came first, then low, then the rally attempt
        if not (hi_idx < lo_idx < rally_idx):
            return None
        if hi_idx >= start:
            return None

        retrace_level = range_low + self._min_retrace * rng
        mid = range_low + self._mid_level * rng
        if rally_high < retrace_level:
            return None
        if cur.close >= mid:
            return None
        if cur.close >= cur.open:
            return None

        closes = [b.close for b in bars]
        sma_val = sma(closes, self._sma_len)
        if sma_val is None:
            return None
        sma_dec = Decimal(str(sma_val))
        if cur.close >= sma_dec:
            return None

        atr_val = atr(bars, self._atr_len)
        if atr_val is None or atr_val <= 0:
            return None
        atr_dec = Decimal(str(atr_val))

        entry = cur.close
        stop = rally_high + self._stop_atr * atr_dec
        target = range_low - self._target_atr * atr_dec
        if not (target < entry < stop):
            return None
        if target <= 0:
            return None
        risk = stop - entry
        reward = entry - target
        if risk <= 0:
            return None
        rr = reward / risk
        if rr < self._min_rr:
            return None

        # --- strength ---
        rng_f = float(rng)
        # rejection depth: how far below midpoint the close sits, relative to rally reach
        reach = (float(rally_high) - float(range_low)) / rng_f
        close_frac = (float(cur.close) - float(range_low)) / rng_f
        rej = max(0.0, reach - close_frac)
        rej_score = min(35, max(0, int(rej / 0.4 * 35)))
        # close location within bar (near low = strong)
        bar_rng = float(cur.high - cur.low)
        if bar_rng <= 0:
            close_pos = 0.0
        else:
            close_pos = (float(cur.high) - float(cur.close)) / bar_rng
        close_score = min(25, max(0, int(close_pos * 25)))
        # volume vs 20d avg
        vols = [float(b.volume) for b in bars[-21:-1]]
        avg_vol = sum(vols) / max(len(vols), 1)
        vr = float(cur.volume) / avg_vol if avg_vol > 0 else 1.0
        vol_score = min(20, max(0, int((vr - 0.8) * 25)))
        # trend: sma slope down over 5 bars
        prev_sma = sma(closes[:-5], self._sma_len)
        trend_score = 0
        if prev_sma is not None and prev_sma > 0:
            slope = (float(sma_val) - float(prev_sma)) / float(prev_sma)
            trend_score = min(20, max(0, int(-slope * 1000)))
        strength = max(0, min(100, rej_score + close_score + vol_score + trend_score))

        return Candidate(
            ticker=ticker,
            side="sell",
            entry=entry,
            stop=stop,
            target=target,
            risk_reward_ratio=rr.quantize(Decimal("0.01")),
            signal_strength=strength,
            thesis=(
                f"Rally off the {self._range_len}-bar selloff low reached {reach:.0%} retracement "
                f"but closed red back below the 50% midpoint and the {self._sma_len}-SMA. "
                "Supply from trapped holders is defending the zone, so continuation toward the leg low is expected."
            ),
            asset_class="equity",
        )

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