Skip to content
The Casebook · An idea an AI invented

Overnight gains, flat intraday, above 50-day average

Compute overnight return = open/prev_close-1 and intraday = close/open-1 over last 20 bars. Enter long at latest close if sum of overnight > +4%, sum of intraday < +1%, and close above 50-SMA. Stop = entry - 2.0*ATR(14). Target = entry + 3.0*ATR(14). Max hold 35 days.
Why the AI thought it might work

Close-to-open returns carry a persistent positive premium (overnight risk-bearing, retail/institutional order imbalance at the open), while open-to-close returns are near zero. A stock whose trailing 20-day sum of overnight returns is strongly positive and whose intraday return sum is flat has a demand pattern from MOC/MOO order flow that repeats per name. It shows directly in open vs prior-close bars and persists because arbitrage across overnight holding is capital- and cost-constrained.

VerdictTested Nov 22, 2026

Loses money

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

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

42 large US stocks, 15 years

Per trade, after costs
−0.167R

Before costs −0.082R

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.167R a trade after costs over 1322 trades (−0.082R before costs). Bull markets, the bulk of trades, came in at −0.196R and beat 0.0% of random-date draws; bear markets were worse at −0.540R. Flat markets were the only positive stretch (0.141R, t 1.42), too few trades to offset the rest.

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,091−0.196R−5.06−3.82 · 691d0.000R · beats 0%+0.049R
Flat174+0.141R1.421.22 · 109d−0.046R · beats 95%+0.080R
Bear57−0.540R−4.04−3.39 · 43d+0.067R · beats 0%+0.655R
All1,322−0.167R−0.003R+0.061R

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.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 OvernightDriftPersistenceLong:
    name = "overnight_drift_persistence_long"
    description = "Persistent positive overnight drift with flat intraday returns, above a rising 50-SMA"

    def __init__(self, window: int = 20, min_overnight_sum: float = 0.04, max_intraday_sum: float = 0.01, min_pos_nights: int = 12, ex_max_min_sum: float = 0.025, swing_lookback: int = 10, atr_buffer: float = 0.25, min_risk_atr: float = 1.5, max_risk_atr: float = 2.5, target_atr: float = 3.0, min_rr: float = 1.6) -> None:
        self._w = window
        self._min_on = min_overnight_sum
        self._max_id = max_intraday_sum
        self._min_pos = min_pos_nights
        self._ex_max = ex_max_min_sum
        self._swing = swing_lookback
        self._buf = atr_buffer
        self._min_risk = min_risk_atr
        self._max_risk = max_risk_atr
        self._tgt_atr = target_atr
        self._min_rr = min_rr

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        if len(bars) < 120:
            return None
        w = self._w
        window = bars[-(w + 1):]
        on_rets = []
        id_rets = []
        for k in range(1, len(window)):
            pc = float(window[k - 1].close)
            op = float(window[k].open)
            cl = float(window[k].close)
            if pc <= 0 or op <= 0:
                return None
            on_rets.append(op / pc - 1.0)
            id_rets.append(cl / op - 1.0)
        on_sum = sum(on_rets)
        id_sum = sum(id_rets)
        if on_sum <= self._min_on or id_sum >= self._max_id:
            return None
        # Persistence: not driven by one gap (e.g. earnings)
        pos_nights = sum(1 for r in on_rets if r > 0)
        if pos_nights < self._min_pos:
            return None
        if on_sum - max(on_rets) < self._ex_max:
            return None
        # Avoid names where intraday selling is collapsing (distribution)
        if id_sum < -0.06:
            return None

        closes = [float(b.close) for b in bars]
        sma50 = sma(closes, 50)
        sma50_prev = sma(closes[:-5], 50)
        if sma50 is None or sma50_prev is None:
            return None
        current = bars[-1]
        c = float(current.close)
        if c <= sma50 or sma50 < sma50_prev:
            return None

        atr_val = atr(bars, 14)
        if atr_val is None or float(atr_val) <= 0:
            return None
        a = float(atr_val)
        # Avoid extended entries far above the 50-SMA
        if (c - sma50) / a > 4.0:
            return None

        swing_low = min(float(b.low) for b in bars[-self._swing:])
        stop_f = swing_low - self._buf * a
        risk = c - stop_f
        if risk < self._min_risk * a:
            stop_f = c - self._min_risk * a
        elif risk > self._max_risk * a:
            stop_f = c - self._max_risk * a
        risk = c - stop_f
        if risk <= 0 or stop_f <= 0:
            return None
        target_f = c + max(self._tgt_atr * a, self._min_rr * risk)

        entry = current.close
        stop = Decimal(str(round(stop_f, 4)))
        target = Decimal(str(round(target_f, 4)))
        if not (stop < entry < target):
            return None
        rr = (target - entry) / (entry - stop)
        if rr < Decimal("1.5"):
            return None

        on_score = min(40, max(0, int((on_sum - self._min_on) / 0.06 * 40)))
        pers_score = min(30, max(0, int((pos_nights - self._min_pos + 1) / (w - self._min_pos + 1) * 30)))
        flat_score = min(15, max(0, int((1.0 - abs(id_sum) / 0.06) * 15)))
        trend_score = min(15, max(0, int((sma50 - sma50_prev) / sma50_prev * 1500)))
        strength = max(0, min(100, on_score + pers_score + flat_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"Overnight drift persistence: 20d overnight sum {on_sum*100:.1f}% "
                f"({pos_nights}/{w} positive nights) vs intraday sum {id_sum*100:.1f}%; "
                f"close above rising 50-SMA. Repeating opening demand expected to persist; "
                f"stop under {self._swing}-day swing low, target ~{self._tgt_atr} ATR."
            ),
        )

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
Overnight gains, flat intraday, above 50-day average: Loses money · EdgeProven