Short late-month after a strong 20-day run and a lower close
Entry at latest close if the latest bar is among the last 2 trading days of a calendar month, 20-day return is above +2.0x ATR(14) percent, and close is below the prior day's close (the first sign of selling). Stop = entry plus 1.3x ATR(14). Target = entry minus 1.6x ATR(14).
Pension and balanced funds rebalance at month end by selling equities after strong months and buying after weak ones; stocks with strong 20-day advances face selling pressure from this mechanical rebalancing in the last days of the month. Condition on stock-specific strength so signals fire at different times per name.
Loses money
After costs it lost money on the stocks that decide the verdict.
- −0.197R a trade after costs on the laggard stocks.
42 large US stocks, 15 years
Before costs −0.081R
By trade and by day, sized to 362 rules
What the numbers say
Across 411 trades on the laggard stocks the idea averaged −0.197R after costs, and −0.321R on the winners. It lost in bull (−0.196R), flat (−0.119R) and bear (−0.580R) markets. In bull markets it beat only 15% of random-date draws, and in bear markets 0%. The verdict follows from the loss in every market type.
How it was tested
The rule as written, coded once, run on every stock the same way.
- Side
- Short
- 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.
| Market | Trades | Per trade | t, by trade | t, by day | Random dates | Winners, per trade |
|---|---|---|---|---|---|---|
| Bull | 304 | −0.196R | −2.42 | −1.75 · 88d | −0.141R · beats 15% | −0.300R |
| Flat | 88 | −0.119R | −0.81 | −0.55 · 29d | −0.122R · beats 55% | −0.389R |
| Bear | 19 | −0.580R | −1.93 | −2.72 · 7d | −0.061R · beats 0% | −0.679R |
| All | 411 | −0.197R | −0.133R | −0.321R |
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.1 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 codeHide
from decimal import Decimal
from datetime import datetime, timedelta
from core.domain import Bar
from strategies.indicators import atr, ema
from scanners.base import Candidate
class MonthEndUpStreakPensionRebalanceShort:
name = "month_end_up_streak_pension_rebalance_short"
description = "Short the first down close on the penultimate trading day of a month after a 20-day advance above 2x ATR%."
def __init__(self, ret_lookback: int = 20, atr_period: int = 14, ret_atr_mult: float = 2.0,
swing_lookback: int = 5, stop_buffer_atr: float = 0.25, min_stop_atr: float = 1.0,
max_stop_atr: float = 1.3, min_target_atr: float = 1.6, max_target_atr: float = 3.0,
min_rr: float = 1.6) -> None:
self._ret_lookback = ret_lookback
self._atr_period = atr_period
self._ret_atr_mult = ret_atr_mult
self._swing_lookback = swing_lookback
self._stop_buffer_atr = stop_buffer_atr
self._min_stop_atr = min_stop_atr
self._max_stop_atr = max_stop_atr
self._min_target_atr = min_target_atr
self._max_target_atr = max_target_atr
self._min_rr = min_rr
@staticmethod
def _weekdays_left_in_month(ts) -> int:
y, m, d = ts.year, ts.month, ts.day
cur = datetime(y, m, d) + timedelta(days=1)
count = 0
while cur.month == m:
if cur.weekday() < 5:
count += 1
cur = cur + timedelta(days=1)
return count
def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
if len(bars) < 220:
return None
current = bars[-1]
prev = bars[-2]
# Penultimate trading day of the month (exactly one weekday left).
# Avoids shorting into the documented positive last-day/turn-of-month window.
try:
left = self._weekdays_left_in_month(current.timestamp)
except Exception:
return None
if left != 1:
return None
# First sign of selling: lower close than prior day
if current.close >= prev.close:
return None
atr_val = atr(bars, self._atr_period)
if atr_val is None or atr_val <= 0:
return None
atr_d = Decimal(str(atr_val))
close = current.close
if close <= 0:
return None
base = bars[-(self._ret_lookback + 1)].close
if base <= 0:
return None
ret_pct = float((close - base) / base) * 100.0
atr_pct = float(atr_d / close) * 100.0
if atr_pct <= 0:
return None
threshold = self._ret_atr_mult * atr_pct
if ret_pct <= threshold:
return None
entry = close
# Stop anchored on the recent swing high, clamped to [1.0, 1.3] ATR
swing_high = max(b.high for b in bars[-self._swing_lookback:])
raw_stop = swing_high + Decimal(str(self._stop_buffer_atr)) * atr_d
risk = raw_stop - entry
min_risk = Decimal(str(self._min_stop_atr)) * atr_d
max_risk = Decimal(str(self._max_stop_atr)) * atr_d
if risk < min_risk:
risk = min_risk
if risk > max_risk:
risk = max_risk
stop = entry + risk
if risk <= 0:
return None
# Target: mean reversion toward 20-EMA, at least 1.6 ATR and min_rr*risk, capped at 3 ATR
closes = [b.close for b in bars]
ema20 = ema(closes, 20)
if ema20 is None:
return None
ema_dist = entry - Decimal(str(ema20))
tgt_dist = max(Decimal(str(self._min_target_atr)) * atr_d,
Decimal(str(self._min_rr)) * risk,
ema_dist)
cap = Decimal(str(self._max_target_atr)) * atr_d
if tgt_dist > cap:
tgt_dist = cap
target = entry - tgt_dist
if target <= 0 or not (target < entry < stop):
return None
rr = (entry - target) / (stop - entry)
if rr < Decimal("1.5"):
return None
# Strength: overextension, decisiveness of the down day, volume
ext_mult = ret_pct / atr_pct
ext_score = min(40, max(0, int((ext_mult - self._ret_atr_mult) * 10)))
drop_atr = float((prev.close - close) / atr_d)
rng = current.high - current.low
if rng <= 0:
rng = Decimal("0.01")
close_pos = float((current.close - current.low) / rng)
decis_score = min(35, max(0, int(min(drop_atr, 1.0) * 20 + (1.0 - close_pos) * 15)))
avg_vol = sum(b.volume for b in bars[-21:-1]) / 20
vol_ratio = float(current.volume) / max(float(avg_vol), 1.0)
vol_score = min(25, max(0, int((vol_ratio - 0.8) * 25)))
strength = max(0, min(100, ext_score + decis_score + vol_score))
return Candidate(
ticker=ticker,
side="sell",
entry=entry,
stop=stop,
target=target,
risk_reward_ratio=rr.quantize(Decimal("0.01")),
signal_strength=strength,
thesis=(f"Penultimate trading day of the month: 20-day gain {ret_pct:.1f}% exceeds "
f"{self._ret_atr_mult}x ATR% ({threshold:.1f}%) and price closed lower. The overweight winner "
f"faces month-end rebalancing and profit-taking supply. Shorting before the turn-of-month "
f"inflow window, targeting reversion toward the 20-EMA."),
)
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.
Describe it in plain words and get the same honest test in about a minute.