MACD histogram turns positive after 10 negative days
Buy when the MACD histogram turns positive after 10 negative days.
Survivorship mirage
It clears the bar on today's winners, the stocks everyone wishes they had bought, but not on the laggards, which is where hindsight can't help.
- It clears the bar on today's winners but not on the laggards: the winners' own rise did the work.
42 large US stocks, 15 years
Before costs +0.068R
By trade and by day, sized to a first try
What the numbers say
On the 22 laggards the idea averaged −0.020R per trade after costs over 1626 trades, while on today's winners it averaged 0.159R. Only the bear-market slice (0.215R, t 2.45 by trade, 2.12 by day) stood out; bull and flat slices were slightly negative. The winners' own rise did the work, hence the verdict.
How it was tested
Buy at the close when the MACD histogram turns positive after being negative for each of the previous 10 trading days.
- Side
- Long
- Time limit
- Exit at the close after 20 trading days, unless the stop, the target or its own exit comes first
- Bar to clear
- t > 2.01, by trade and by day, sized to a first try (one idea, tested once)
- Prices
- 15 years of daily bars through 2026-11-20; judged 2026-11-22
- MACD uses the standard 12/26/9 settings on closing prices
- Histogram = MACD line minus 9-day EMA signal line
- 'After 10 negative days' means exactly the 10 trading days immediately before the turn all had histogram below 0 (a run of 10 or more qualifies)
- 'Turns positive' means histogram above 0 on the signal day
- No stop or target was given: stop 2 x ATR(14) below entry, target 4 x ATR(14) above entry
- No hold period was given: exit at the close after 20 trading days if neither stop nor target is hit
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 | 1,173 | −0.053R | −1.46 | −0.97 · 809d | −0.040R · beats 25% | +0.199R |
| Flat | 284 | −0.022R | −0.30 | −0.10 · 189d | −0.005R · beats 40% | +0.044R |
| Bear | 169 | +0.215R | 2.45 | 2.12 · 89d | +0.110R · beats 90% | +0.056R |
| All | 1,626 | −0.020R | −0.018R | +0.159R |
R is the result per trade in units of the risk taken (entry to stop). Costs are each stock's own trading spread (median 12.7 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 core.domain import Bar
from strategies.indicators import atr
from scanners.base import Candidate
def _ema_series(values, period):
# SMA-seeded EMA; returns list aligned to values[period-1:]
if len(values) < period:
return []
k = 2.0 / (period + 1)
cur = sum(values[:period]) / period
out = [cur]
for v in values[period:]:
cur = v * k + cur * (1 - k)
out.append(cur)
return out
class MacdHistPositiveAfter10Negative:
name = "macd_hist_positive_after_10_negative_days"
description = "MACD histogram turns positive after 10 consecutive negative days (long)"
def __init__(self, fast: int = 12, slow: int = 26, signal: int = 9,
neg_days: int = 10, atr_period: int = 14,
stop_mult: float = 2.0, target_mult: float = 4.0) -> None:
self._fast = fast
self._slow = slow
self._signal = signal
self._neg_days = neg_days
self._atr_period = atr_period
self._stop_mult = stop_mult
self._target_mult = target_mult
def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
min_bars = self._slow + self._signal - 1 + self._neg_days
if len(bars) < max(min_bars, self._atr_period + 1):
return None
closes = [float(b.close) for b in bars]
fast_e = _ema_series(closes, self._fast)
slow_e = _ema_series(closes, self._slow)
if not slow_e:
return None
# align: slow_e[i] corresponds to closes index slow-1+i
offset = self._slow - self._fast
macd_line = [fast_e[offset + i] - slow_e[i] for i in range(len(slow_e))]
sig = _ema_series(macd_line, self._signal)
if not sig:
return None
# sig[j] aligns with macd_line[signal-1+j]
hist = [macd_line[self._signal - 1 + j] - sig[j] for j in range(len(sig))]
if len(hist) < self._neg_days + 1:
return None
if not hist[-1] > 0:
return None
for h in hist[-(self._neg_days + 1):-1]:
if not h < 0:
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))
entry = bars[-1].close
stop = entry - Decimal(str(self._stop_mult)) * atr_dec
target = entry + Decimal(str(self._target_mult)) * atr_dec
risk = entry - stop
if risk <= 0 or stop <= 0:
return None
rr = (target - entry) / risk
return Candidate(
ticker=ticker,
side="buy",
entry=entry,
stop=stop,
target=target,
risk_reward_ratio=rr.quantize(Decimal("0.01")),
signal_strength=50,
thesis=f"MACD histogram turned positive after {self._neg_days} consecutive negative days.",
)
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.