Skip to content
The Casebook · An idea an AI invented

Four of five strong closes, above 50-day average

Entry at latest close if at least 4 of the last 5 closes were in the top 25% of their day's range, the latest 10-day return is below 2.5x ATR(14) percent (not extended), and close is above the 50-day SMA. Stop = lowest low of the last 5 bars minus 0.2x ATR(14). Target = entry plus 2x ATR(14).
Why the AI thought it might work

Persistent closes near the day's high across several sessions show sustained end-of-day institutional buying (funds completing VWAP-style programs into the close), which is order-flow persistence from compelled large buyers working multi-day orders. Four of five closes in the top 20% of the range, without extension, marks that accumulation.

VerdictTested Nov 22, 2026

Loses money

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

  • −0.082R a trade after costs on the laggard stocks.
Trades on the laggards
271

42 large US stocks, 15 years

Per trade, after costs
−0.082R

Before costs +0.037R

Bar to clear
t > 2.95

By trade and by day, sized to 362 rules

What the numbers say

On the laggard stocks, 271 trades averaged −0.082R after costs, against 0.287R on the winners. Costs account for the gap from 0.037R before costs. In bull markets, which hold 202 of the trades, the result was −0.155R, and only 10% of random-date draws were beaten. The positive flat and bear results rest on 59 and 10 trades.

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
Bull202−0.155R−1.55−1.91 · 179d−0.055R · beats 10%+0.174R
Flat59+0.089R0.470.50 · 50d+0.003R · beats 80%+0.516R
Bear10+0.398R0.750.76 · 9d−0.084R · beats 75%+1.686R
All271−0.082R−0.043R+0.287R

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 CloseLocationPersistenceLong:
    name = "close_location_persistence_long"
    description = "4 of last 5 closes in top 25% of range, not extended, above 50-SMA: persistent end-of-day buying"

    def __init__(self, window: int = 5, min_strong: int = 4, clv_threshold: float = 0.75,
                 ext_atr_mult: float = 2.5, stop_atr_buffer: float = 0.2,
                 target_atr_mult: float = 2.0, min_rr: float = 1.6,
                 max_risk_atr: float = 2.0, sma_len: int = 50) -> None:
        self._window = window
        self._min_strong = min_strong
        self._clv = clv_threshold
        self._ext = ext_atr_mult
        self._buf = stop_atr_buffer
        self._tgt = target_atr_mult
        self._min_rr = min_rr
        self._max_risk_atr = max_risk_atr
        self._sma_len = sma_len

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        if len(bars) < max(self._sma_len, 30) + 10:
            return None
        cur = bars[-1]
        closes = [float(b.close) for b in bars]
        c = closes[-1]
        if c <= 0:
            return None

        sma50 = sma(closes, self._sma_len)
        if sma50 is None or c <= float(sma50):
            return None

        atr_val = atr(bars, 14)
        if atr_val is None or float(atr_val) <= 0:
            return None
        a = float(atr_val)

        recent = bars[-self._window:]
        clvs = []
        strong = 0
        for b in recent:
            rng = float(b.high) - float(b.low)
            if rng <= 0:
                clvs.append(0.5)
                continue
            v = (float(b.close) - float(b.low)) / rng
            clvs.append(v)
            if v >= self._clv:
                strong += 1
        if strong < self._min_strong:
            return None

        c10 = closes[-11]
        if c10 <= 0:
            return None
        ret10_pct = (c / c10 - 1.0) * 100.0
        atr_pct = a / c * 100.0
        if ret10_pct >= self._ext * atr_pct:
            return None

        low5 = min(float(b.low) for b in recent)
        stop_f = low5 - self._buf * a
        risk_f = c - stop_f
        if risk_f <= 0 or risk_f > self._max_risk_atr * a:
            return None
        # Operator target is entry + 2 ATR; widened only when needed to clear the R:R floor
        reward_f = max(self._tgt * a, self._min_rr * risk_f)

        entry = cur.close
        stop = Decimal(str(round(stop_f, 4)))
        target = Decimal(str(round(c + reward_f, 4)))
        if not (stop < entry < target):
            return None
        risk = entry - stop
        rr = (target - entry) / risk
        if rr <= Decimal("1.5"):
            return None

        # Strength: persistence quality, volume, trend-not-extended
        avg_clv = sum(clvs) / len(clvs)
        persist_score = (10 if strong == self._window else 0) + int(max(0.0, min(1.0, (avg_clv - 0.6) / 0.4)) * 30)
        vols = [float(b.volume) for b in bars[-25:-5]]
        avg_vol = sum(vols) / len(vols) if vols else 0.0
        rec_vol = sum(float(b.volume) for b in recent) / len(recent)
        vratio = rec_vol / avg_vol if avg_vol > 0 else 1.0
        vol_score = int(max(0.0, min(1.0, (vratio - 0.8) / 0.7)) * 30)
        ext_frac = ret10_pct / (self._ext * atr_pct) if atr_pct > 0 else 1.0
        ext_score = int(max(0.0, min(1.0, 1.0 - ext_frac)) * 15)
        risk_atr = risk_f / a
        tight_score = int(max(0.0, min(1.0, (self._max_risk_atr - risk_atr) / self._max_risk_atr)) * 15)
        strength = max(0, min(100, persist_score + vol_score + ext_score + tight_score))

        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=(f"{strong}/{self._window} closes in the top 25% of range (avg CLV {avg_clv:.2f}), "
                    f"10d return {ret10_pct:.1f}% vs extension cap {self._ext * atr_pct:.1f}%, above 50-SMA: "
                    f"persistent end-of-day buying from multi-day institutional orders, not yet extended."),
        )

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