Skip to content
The Casebook · An idea an AI invented

Strong close near the day's high on a narrow range, long

Condition: close is in the top 10% of the day's range, close greater than open by at least 1.0x ATR(14)/2, the day's range is smaller than 1.2x the 20-day average range, and close above the 50-day SMA. Entry long at close. Stop at the day's low. Target 2x the stop distance, capped by position within 35 days.
Why the AI thought it might work

Volatility-targeting and trend-following funds scale exposure with realized vol; when a stock opens strongly and closes near its high with a range contraction versus recent days, forced late-day buyers (index and closing-auction demand) imply a bid that carries into the next sessions. Daily bars reveal the open-to-close drift with close-at-high structure.

VerdictTested Nov 22, 2026

Loses money

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

  • −0.178R a trade after costs on the laggard stocks.
Trades on the laggards
1,572

42 large US stocks, 15 years

Per trade, after costs
−0.178R

Before costs −0.021R

Bar to clear
t > 2.95

By trade and by day, sized to 362 rules

What the numbers say

On the laggard stocks, 1572 trades averaged −0.178R after costs, and −0.020813394095626034R before costs. Bull markets came to −0.194R, beating 0.0% of random-date draws. Winners stood at −0.037R. Only the 69 bear-market trades reached 0.007R, a t of 0.03.

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
Bull1,258−0.194R−4.20−3.19 · 809d−0.101R · beats 0%−0.067R
Flat245−0.148R−1.55−1.98 · 156d−0.036R · beats 10%+0.051R
Bear69+0.007R0.030.12 · 46d−0.133R · beats 65%+0.277R
All1,572−0.178R−0.092R−0.037R

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.9 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 CloseAtHighContractedRangeDriftLong:
    name = "close_at_high_contracted_range_drift_long"
    description = "Close in top 10% of range with open-to-close drift >= 0.5 ATR on a non-expanded range, above 50/200 SMA"

    def __init__(self, close_pos_min: float = 0.90, body_atr_mult: float = 0.5,
                 range_mult_max: float = 1.2, range_lookback: int = 20,
                 atr_period: int = 14, sma_fast: int = 50, sma_slow: int = 200,
                 require_sma_slow: bool = True, target_r: float = 2.0,
                 min_risk_pct: float = 0.004) -> None:
        self._close_pos_min = close_pos_min
        self._body_atr_mult = body_atr_mult
        self._range_mult_max = range_mult_max
        self._range_lookback = range_lookback
        self._atr_period = atr_period
        self._sma_fast = sma_fast
        self._sma_slow = sma_slow
        self._require_sma_slow = require_sma_slow
        self._target_r = target_r
        self._min_risk_pct = min_risk_pct

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        if len(bars) < 220:
            return None
        cur = bars[-1]
        high = Decimal(str(cur.high))
        low = Decimal(str(cur.low))
        close = Decimal(str(cur.close))
        opn = Decimal(str(cur.open))
        day_range = high - low
        if day_range <= 0 or close <= 0:
            return None

        close_pos = (close - low) / day_range
        if close_pos < Decimal(str(self._close_pos_min)):
            return None

        atr_val = atr(bars, self._atr_period)
        if atr_val is None or atr_val <= 0:
            return None
        atr_dec = Decimal(str(atr_val))
        body = close - opn
        if body < Decimal(str(self._body_atr_mult)) * atr_dec:
            return None

        prior = bars[-(self._range_lookback + 1):-1]
        if len(prior) < self._range_lookback:
            return None
        avg_range = sum((Decimal(str(b.high)) - Decimal(str(b.low))) for b in prior) / Decimal(len(prior))
        if avg_range <= 0:
            return None
        range_ratio = day_range / avg_range
        if range_ratio >= Decimal(str(self._range_mult_max)):
            return None

        closes = [b.close for b in bars]
        sma_f = sma(closes, self._sma_fast)
        if sma_f is None or close <= Decimal(str(sma_f)):
            return None
        sma_s = sma(closes, self._sma_slow)
        if self._require_sma_slow:
            if sma_s is None or close <= Decimal(str(sma_s)):
                return None

        entry = close
        stop = low
        risk = entry - stop
        if risk <= 0:
            return None
        if risk / entry < Decimal(str(self._min_risk_pct)):
            return None
        target = entry + Decimal(str(self._target_r)) * risk
        rr = (target - entry) / risk
        if rr < Decimal("1.5"):
            return None

        # Strength components
        cp = float(close_pos)
        close_score = int(max(0.0, min(25.0, (cp - 0.90) / 0.10 * 25.0)))
        body_atr = float(body / atr_dec)
        body_score = int(max(0.0, min(25.0, (body_atr - 0.5) / 1.0 * 25.0)))
        rr_f = float(range_ratio)
        contraction_score = int(max(0.0, min(20.0, (1.2 - rr_f) / 0.6 * 20.0)))
        avg_vol = sum(float(b.volume) for b in prior) / max(len(prior), 1)
        vol_ratio = float(cur.volume) / max(avg_vol, 1.0)
        vol_score = int(max(0.0, min(15.0, (vol_ratio - 0.8) / 0.8 * 15.0)))
        trend_score = 0
        sf = float(sma_f)
        if sma_s is not None and sf > float(sma_s):
            trend_score += 8
        if len(bars) > self._sma_fast + 10:
            sma_f_prev = sma([b.close for b in bars[:-10]], self._sma_fast)
            if sma_f_prev is not None and sf > float(sma_f_prev):
                trend_score += 7
        strength = max(0, min(100, close_score + body_score + contraction_score + vol_score + trend_score))

        thesis = (
            f"Open-to-close drift of {body_atr:.2f} ATR finishing at {cp*100:.0f}% of the range, "
            f"with range only {rr_f:.2f}x the {self._range_lookback}-day average and price above the 50-day SMA. "
            "Steady late-day demand without a volatility expansion suggests continuation buying over the next sessions. "
            "Stop at the day's low; target 2R."
        )

        return Candidate(
            ticker=ticker,
            side="buy",
            entry=entry,
            stop=stop,
            target=target,
            risk_reward_ratio=rr.quantize(Decimal("0.01")),
            signal_strength=int(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
Strong close near the day's high on a narrow range, long: Loses money · EdgeProven