Skip to content
The Casebook · An idea an AI invented

Month-start entry at a 20-day high, above 100-day average

Entry at latest close if it is among the first 3 trading days of the calendar month (by date), the close is at a 20-day high, and the close is above the 100-day SMA. Stop 1.5 ATR below entry. Target 3 ATR above.
Why the AI thought it might work

Monthly retirement-plan and fund inflows are invested in the first few sessions of a month, concentrated in stocks already attracting buying. In names closing at 20-day highs during the first 3 trading days of the month, inflow demand continues rather than fades, which is stock-specific (the condition is relative strength) and not merely calendar.

VerdictTested Nov 22, 2026

Loses money

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

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

42 large US stocks, 15 years

Per trade, after costs
−0.094R

Before costs +0.009R

Bar to clear
t > 2.95

By trade and by day, sized to 362 rules

What the numbers say

On the laggard stocks, 1425 trades averaged −0.094R after costs, against 0.009R before costs, so trading costs account for the loss. Bull markets were weakest at −0.144R across 1119 trades, and no random-date draw did worse (0.0% beaten). Flat markets showed 0.147R, but with a day-based t of 0.73 that is weak. The 20 current winners averaged 0.087R.

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,119−0.144R−3.26−2.65 · 300d−0.058R · beats 0%+0.103R
Flat238+0.147R1.540.73 · 72d−0.004R · beats 95%−0.015R
Bear68−0.122R−0.71−0.51 · 21d+0.013R · beats 20%+0.111R
All1,425−0.094R−0.045R+0.087R

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 MonthStartInflowStrengthContinuationLong:
    name = "month_start_inflow_strength_continuation_long"
    description = "Close at 20-day closing high above 100-SMA during first 3 trading days of the month (mid_month mode = control)."

    def __init__(self, lookback: int = 20, sma_len: int = 100, atr_len: int = 14,
                 stop_atr: float = 1.5, target_atr: float = 3.0,
                 max_tdom: int = 3, mode: str = "month_start",
                 control_lo: int = 8, control_hi: int = 12) -> None:
        self._lookback = lookback
        self._sma_len = sma_len
        self._atr_len = atr_len
        self._stop_atr = stop_atr
        self._target_atr = target_atr
        self._max_tdom = max_tdom
        self._mode = mode
        self._control_lo = control_lo
        self._control_hi = control_hi

    def _trading_day_of_month(self, bars):
        last = bars[-1].timestamp
        y, m = last.year, last.month
        count = 1
        j = len(bars) - 2
        while j >= 0:
            t = bars[j].timestamp
            if t.year == y and t.month == m:
                count += 1
                j -= 1
            else:
                return count
        return None

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        need = max(self._sma_len, self._lookback, self._atr_len) + 25
        if len(bars) < need:
            return None
        tdom = self._trading_day_of_month(bars)
        if tdom is None:
            return None
        if self._mode == "mid_month":
            if tdom < self._control_lo or tdom > self._control_hi:
                return None
        else:
            if tdom > self._max_tdom:
                return None

        cur = bars[-1]
        prior = bars[-self._lookback:-1]
        prior_close_high = max(b.close for b in prior)
        if cur.close < prior_close_high:
            return None

        closes = [b.close for b in bars]
        sma_v = sma(closes, self._sma_len)
        if sma_v is None:
            return None
        sma_d = Decimal(str(sma_v))
        if sma_d <= 0 or cur.close <= sma_d:
            return None

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

        entry = cur.close
        stop = entry - Decimal(str(self._stop_atr)) * atr_d
        target = entry + Decimal(str(self._target_atr)) * atr_d
        if stop <= 0 or not (stop < entry < target):
            return None
        risk = entry - stop
        rr = (target - entry) / risk
        if rr < Decimal("1.5"):
            return None

        vols = [b.volume for b in bars[-21:-1]]
        avg_vol = sum(vols) / len(vols) if vols else 0
        vol_ratio = float(cur.volume) / float(avg_vol) if avg_vol and float(avg_vol) > 0 else 1.0
        vol_score = min(35, max(0, int((vol_ratio - 0.8) * 35)))

        rng = cur.high - cur.low
        close_pos = float((cur.close - cur.low) / rng) if rng > 0 else 0.5
        close_score = min(25, max(0, int(close_pos * 25)))

        ext = float((cur.close - sma_d) / sma_d)
        if ext <= 0.15:
            trend_score = int(min(25.0, ext / 0.15 * 25))
        else:
            trend_score = max(5, int(25 - (ext - 0.15) * 100))

        early_score = max(0, 15 - (tdom - 1) * 5) if self._mode != "mid_month" else 5
        strength = max(0, min(100, vol_score + close_score + trend_score + early_score))

        tag = "MID-MONTH CONTROL" if self._mode == "mid_month" else "month-start inflow window"
        thesis = (
            f"{tag}: trading day {tdom} of month; close {entry} at {self._lookback}-day closing high "
            f"above {self._sma_len}-SMA {sma_d.quantize(Decimal('0.01'))}. Hypothesis: early-month fund/retirement "
            f"inflows concentrate in names already showing relative strength, so demand continues. "
            f"Vol {vol_ratio:.2f}x avg; stop {self._stop_atr} ATR, target {self._target_atr} ATR."
        )
        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
Month-start entry at a 20-day high, above 100-day average: Loses money · EdgeProven