Skip to content
The Casebook · A classic strategy

Close above the upper Keltner channel (20 EMA + 2 ATR)

Buy stocks that close above the upper Keltner channel (20 EMA plus 2 ATR) as a momentum breakout.
VerdictTested Nov 22, 2026

Loses money

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

  • −0.069R a trade after costs on the laggard stocks.
Trades on the laggards
2,056

42 large US stocks, 15 years

Per trade, after costs
−0.069R

Before costs +0.019R

Bar to clear
t > 2.01

By trade and by day, sized to a first try

What the numbers say

On the 22 laggard stocks, 2056 trades averaged −0.069R after costs, versus 0.019R before costs, so costs turned a small gain into a loss. Bull (−0.078R) and flat (−0.154R) markets were both negative; only bear markets were positive (0.331R, 103 trades). The 20 winners averaged 0.151R.

How it was tested

Go long at the close of any day a stock closes above its upper Keltner channel (20-day EMA plus 2 x ATR(20)), betting on momentum continuation.

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
Choices made where the idea was open
  • Keltner channel uses the conventional 20-period EMA of close as the midline and ATR with a 20-period Wilder smoothing.
  • Breakout counts only on the first close above the upper band (prior close at or below the band) to avoid re-entering during an ongoing run.
  • Idea named no stop or target, so a 2 x ATR(20) stop and a 4 x ATR(20) target (2:1 reward-to-risk) were chosen.
  • Idea named no holding period, so a 20 trading day time limit was chosen.
  • Entry is at the signal day's close, as the harness requires.

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,650−0.078R−2.46−2.25 · 1,017d−0.025R · beats 5%+0.133R
Flat303−0.154R−2.30−2.70 · 197d−0.038R · beats 5%+0.257R
Bear103+0.331R2.892.30 · 64d+0.118R · beats 95%+0.203R
All2,056−0.069R−0.019R+0.151R

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.9 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 scanners.base import Candidate


class KeltnerUpperCloseFirstBreakout:
    name = "keltner_upper_close_first_breakout"
    description = "First close above EMA20 + 2*ATR20 (Keltner upper band); long with 2 ATR stop and 4 ATR target"

    def __init__(self, ema_period: int = 20, atr_period: int = 20, band_mult: float = 2.0,
                 stop_mult: float = 2.0, target_mult: float = 4.0, max_bars: int = 300) -> None:
        self._ema_period = ema_period
        self._atr_period = atr_period
        self._band_mult = band_mult
        self._stop_mult = stop_mult
        self._target_mult = target_mult
        self._max_bars = max_bars

    def _series(self, bars):
        closes = [float(b.close) for b in bars]
        n = len(closes)
        p = self._ema_period
        ema_s = [None] * n
        if n < p:
            return None, None
        e = sum(closes[:p]) / p
        ema_s[p - 1] = e
        k = 2.0 / (p + 1)
        for i in range(p, n):
            e = closes[i] * k + e * (1 - k)
            ema_s[i] = e
        q = self._atr_period
        trs = [0.0] * n
        for i in range(1, n):
            h = float(bars[i].high)
            l = float(bars[i].low)
            pc = closes[i - 1]
            trs[i] = max(h - l, abs(h - pc), abs(l - pc))
        atr_s = [None] * n
        if n < q + 1:
            return None, None
        a = sum(trs[1:q + 1]) / q
        atr_s[q] = a
        for i in range(q + 1, n):
            a = (a * (q - 1) + trs[i]) / q
            atr_s[i] = a
        return ema_s, atr_s

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        minimum = max(self._ema_period, self._atr_period) * 3
        if len(bars) < minimum:
            return None
        window = bars[-self._max_bars:]
        ema_s, atr_s = self._series(window)
        if ema_s is None:
            return None
        e1, e0 = ema_s[-1], ema_s[-2]
        a1, a0 = atr_s[-1], atr_s[-2]
        if e1 is None or e0 is None or a1 is None or a0 is None or a1 <= 0:
            return None
        current = window[-1]
        prev = window[-2]
        upper1 = e1 + self._band_mult * a1
        upper0 = e0 + self._band_mult * a0
        c1 = float(current.close)
        c0 = float(prev.close)
        if not (c1 > upper1 and c0 <= upper0):
            return None

        atr_dec = Decimal(str(a1))
        entry = current.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
        if rr < Decimal("1.5"):
            return None

        excess = (c1 - upper1) / a1
        excess_score = min(35, max(0, int(excess * 70)))
        prior_vols = [float(b.volume) for b in window[-21:-1]]
        avg_vol = sum(prior_vols) / max(len(prior_vols), 1)
        vol_ratio = float(current.volume) / max(avg_vol, 1.0)
        vol_score = min(35, max(0, int((vol_ratio - 1) * 35)))
        rng = float(current.high - current.low)
        pos = (c1 - float(current.low)) / rng if rng > 0 else 0.5
        close_score = min(30, max(0, int(pos * 30)))
        strength = max(0, min(100, excess_score + vol_score + close_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="First close above the upper Keltner band (EMA20 + 2*ATR20) signals momentum expansion; expecting continuation with 2 ATR stop and 4 ATR target.",
        )

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
Close above the upper Keltner channel (20 EMA + 2 ATR): Loses money · EdgeProven