CCI(20) buy on cross above −100, exit above 100
Buy when CCI(20) crosses above -100 from below and exit when it crosses above 100.
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.055R
By trade and by day, sized to a first try
What the numbers say
On the 22 laggards, 3,523 trades averaged −0.020R after costs (0.055R before), while today's winners averaged 0.040R. In bull and flat markets the laggards stayed negative (−0.022 and −0.031R) and only bear markets were near zero (0.009R). The result appears only on stocks that kept rising, so the verdict is a survivorship mirage.
How it was tested
Buy at the close when CCI(20) crosses up through -100, and exit at the first close where CCI(20) crosses up through +100.
- Side
- Long
- Its own exit
- Exit at the close of the first day after entry where CCI(20) was at or below 100 the prior bar and is above 100 today (cross up through +100)., checked at each close
- 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.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
- CCI uses the standard formula: (typical price - 20-bar SMA of typical price) / (0.015 x 20-bar mean absolute deviation)
- Cross above -100 means previous close CCI <= -100 and current close CCI > -100
- Cross above 100 means previous close CCI <= 100 and current close CCI > 100
- No stop or target was given, so a 3 x ATR(14) stop and 6 x ATR(14) target are chosen as wide protective levels
- No time limit was given, so the maximum of 30 trading days is used
- Entry is at the close of the signal day
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 | 2,412 | −0.022R | −1.38 | −1.44 · 1,278d | −0.042R · beats 75% | +0.066R |
| Flat | 693 | −0.031R | −1.07 | −1.33 · 309d | −0.057R · beats 75% | −0.042R |
| Bear | 418 | +0.009R | 0.27 | 0.85 · 163d | +0.039R · beats 40% | +0.047R |
| All | 3,523 | −0.020R | −0.036R | +0.040R |
R is the result per trade in units of the risk taken (entry to stop). Costs are each stock's own trading spread (median 14.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 core.domain import Bar
from strategies.indicators import atr
from scanners.base import Candidate
def _cci_at(bars, end_idx, period):
# CCI computed using bars[end_idx-period+1 .. end_idx] inclusive
start = end_idx - period + 1
if start < 0:
return None
tps = [(b.high + b.low + b.close) / Decimal(3) for b in bars[start:end_idx + 1]]
mean = sum(tps) / Decimal(period)
md = sum(abs(t - mean) for t in tps) / Decimal(period)
if md == 0:
return None
return float((tps[-1] - mean) / (Decimal("0.015") * md))
class CciCrossAboveMinus100:
name = "cci20_cross_above_minus100_exit_above_100"
description = "Long when CCI(20) crosses up through -100; exit when CCI(20) crosses up through +100."
def __init__(self, period: int = 20, entry_level: float = -100.0, exit_level: float = 100.0,
atr_period: int = 14, stop_mult: float = 3.0, target_mult: float = 6.0) -> None:
self._period = period
self._entry_level = entry_level
self._exit_level = exit_level
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:
if len(bars) < max(self._period + 1, self._atr_period + 1):
return None
cur = _cci_at(bars, len(bars) - 1, self._period)
prev = _cci_at(bars, len(bars) - 2, self._period)
if cur is None or prev is None:
return None
if not (prev <= self._entry_level and cur > self._entry_level):
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="CCI(20) crossed up through -100; exit on CCI cross up through +100.",
)
def exit_now(self, ticker: str, bars: list[Bar], entry: Decimal,
side: str, bars_held: int) -> bool:
if side != "buy":
return False
if len(bars) < self._period + 1:
return False
cur = _cci_at(bars, len(bars) - 1, self._period)
prev = _cci_at(bars, len(bars) - 2, self._period)
if cur is None or prev is None:
return False
return prev <= self._exit_level and cur > self._exit_level
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.