Skip to content
The Casebook · An idea an AI invented

Pullback of 6-10% from a near-52-week high, in an uptrend

Require that within the last 15 bars the close reached within 3% of the 252-bar high, current close is 6% to 10% below that recent peak, close above the 100-SMA with the 100-SMA rising, and today's close above the prior close. Enter long at the latest close; stop 1.5 x ATR(14) below; target the recent peak or 3 x ATR(14), whichever is smaller.
Why the AI thought it might work

Stocks within 3% of the 52-week high attract anchored buying by fund managers who reference the high and by momentum screens. A sharp 3 to 5 day pullback of 6 to 10% from that anchor into a still-rising 100-day average is a transient shakeout where weak momentum chasers exit, while anchored institutional demand reappears near the old breakout level. The compelled party is the benchmark-hugging manager underweight the strong name.

VerdictTested Nov 22, 2026

Loses money

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

  • −0.124R a trade after costs on the laggard stocks.
Trades on the laggards
206

42 large US stocks, 15 years

Per trade, after costs
−0.124R

Before costs −0.034R

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.124R a trade after costs over 206 trades, and −0.0342736681995305R before costs, so costs were not the only drag. Bull markets were weakest at −0.172R over 159 trades, beating 5% of random-date draws. The 20 current winners averaged 0.131R, a gap that does not carry over to the laggards.

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
Bull159−0.172R−1.43−1.12 · 131d−0.043R · beats 5%+0.178R
Flat29+0.165R0.630.60 · 24d−0.004R · beats 70%+0.032R
Bear18−0.166R−0.52−0.39 · 16d−0.071R · beats 45%−0.420R
All206−0.124R−0.040R+0.131R

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


class First52wkPullbackLong:
    name = "first_oversold_close_after_52wk_high_failure_long"
    description = "First up-close after a 6-10% pullback from a near-52wk-high peak above a rising 100-SMA"

    def __init__(self, lookback: int = 15, near_high_pct: float = 0.03, dd_min: float = 0.06, dd_max: float = 0.10, sma_len: int = 100, slope_lag: int = 10, stop_atr: float = 1.5, target_atr: float = 3.0) -> None:
        self._lb = lookback
        self._near = near_high_pct
        self._dd_min = dd_min
        self._dd_max = dd_max
        self._sma_len = sma_len
        self._lag = slope_lag
        self._stop_atr = stop_atr
        self._target_atr = target_atr

    def _sma(self, vals, end, n):
        if end < n:
            return None
        return sum(vals[end - n:end]) / n

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        n = len(bars)
        if n < 252 + self._lb + 5:
            return None
        closes = [float(b.close) for b in bars]
        highs = [float(b.high) for b in bars]
        i = n - 1
        cur = bars[-1]
        c = closes[i]
        if c <= closes[i - 1]:
            return None

        # recent peak (prior to today) in last lookback bars
        start = i - self._lb
        peak = -1.0
        peak_idx = -1
        for j in range(start, i):
            if highs[j] > peak:
                peak = highs[j]
                peak_idx = j
        if peak_idx < 0 or peak <= 0:
            return None

        # some close in the window came within near% of the 252-bar high as of that bar
        near_ok = False
        for j in range(start, i):
            hh = max(highs[j - 251:j + 1])
            if closes[j] >= hh * (1.0 - self._near):
                near_ok = True
                break
        if not near_ok:
            return None

        dd = (peak - c) / peak
        if dd < self._dd_min or dd > self._dd_max:
            return None

        sma_now = self._sma(closes, i + 1, self._sma_len)
        sma_prev = self._sma(closes, i + 1 - self._lag, self._sma_len)
        if sma_now is None or sma_prev is None:
            return None
        if c <= sma_now or sma_now <= sma_prev:
            return None

        # 'first': no earlier qualifying up-close since the peak
        for j in range(peak_idx + 1, i):
            ddj = (peak - closes[j]) / peak
            if self._dd_min <= ddj <= self._dd_max and closes[j] > closes[j - 1] and closes[j] > sma_now:
                return None

        atr_val = atr(bars, 14)
        if atr_val is None or float(atr_val) <= 0:
            return None
        a = float(atr_val)
        entry = cur.close
        stop = entry - Decimal(str(round(self._stop_atr * a, 6)))
        tgt_peak = Decimal(str(round(peak, 6)))
        tgt_atr = entry + Decimal(str(round(self._target_atr * a, 6)))
        target = min(tgt_peak, tgt_atr)
        risk = entry - stop
        if risk <= 0 or target <= entry or stop <= 0:
            return None
        rr = (target - entry) / risk
        if rr < Decimal("1.5"):
            return None

        # scoring
        bars_since_peak = i - peak_idx
        speed_score = max(0, min(30, int(30 - max(0, bars_since_peak - 3) * 3)))
        vols = [float(b.volume) for b in bars[-21:-1]]
        avg_vol = sum(vols) / max(len(vols), 1)
        vr = float(cur.volume) / max(avg_vol, 1.0)
        vol_score = max(0, min(25, int(vr * 15)))
        rng = float(cur.high - cur.low)
        cpos = (c - float(cur.low)) / rng if rng > 0 else 0.5
        close_score = max(0, min(20, int(cpos * 20)))
        slope = (sma_now - sma_prev) / sma_prev
        trend_score = max(0, min(25, int(slope * 2500)))
        strength = max(0, min(100, speed_score + vol_score + close_score + trend_score))

        return Candidate(
            ticker=ticker,
            side="buy",
            entry=entry,
            stop=stop,
            target=target,
            risk_reward_ratio=rr.quantize(Decimal("0.01")),
            signal_strength=strength,
            thesis=(f"First up-close after a {dd*100:.1f}% pullback over {bars_since_peak} bars from a near-52wk-high peak; "
                    f"price holds above a rising 100-SMA, so anchored institutional demand should reclaim the peak."),
        )

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
Pullback of 6-10% from a near-52-week high, in an uptrend: Loses money · EdgeProven