Skip to content
The Casebook · An idea an AI invented

Buy a close 2.5 ATR under 20-day VWAP, up-bar, VWAP target

Entry at latest close if close < 20-day VWAP (using typical price weighted by volume) minus 2.5*ATR(14), and the latest bar closed above its open. Stop = low of the last 3 bars minus 0.3*ATR(14). Target = 20-day VWAP or entry + 3*ATR(14), whichever is closer to entry.
Why the AI thought it might work

Institutional buy programs are benchmarked to volume-weighted average price. When price closes more than 2.5*ATR below the 20-day volume-weighted average price after a decline on rising volume, benchmarked buyers have a strong incentive to execute below VWAP. This creates a bid on stretched stocks. Computable from daily typical price and volume.

VerdictTested Nov 22, 2026

Loses money

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

  • −0.086R a trade after costs on the laggard stocks.
Trades on the laggards
615

42 large US stocks, 15 years

Per trade, after costs
−0.086R

Before costs +0.024R

Bar to clear
t > 2.95

By trade and by day, sized to 362 rules

What the numbers say

Across 615 trades on the laggard stocks, the idea averaged −0.086R after costs, against 0.081R on the winners. Before costs it was about 0.024R, so trading costs account for the loss. Bull (−0.023R) and flat (−0.080R) were near the random-date averages, while bear markets were weakest at −0.280R (t −2.14), beating 0.0% of random draws.

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
Bull350−0.023R−0.23−0.84 · 281d−0.104R · beats 70%+0.123R
Flat146−0.080R−0.44−0.30 · 103d−0.091R · beats 50%+0.106R
Bear119−0.280R−2.14−1.84 · 66d+0.067R · beats 0%−0.014R
All615−0.086R−0.068R+0.081R

R is the result per trade in units of the risk taken (entry to stop). Costs are each stock's own trading spread (median 8.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 Vwap20StretchForcedBuyerLong:
    name = "vwap20_stretch_forced_buyer_long"
    description = "Close >2.5 ATR below 20-day VWAP after a rising-volume decline, with a green bar; target reversion toward VWAP."

    def __init__(self, vwap_len: int = 20, atr_len: int = 14, stretch_atr: float = 2.5,
                 stop_buf_atr: float = 0.3, target_cap_atr: float = 3.0,
                 recent_vol_len: int = 5, decline_len: int = 10, min_bars: int = 60) -> None:
        self._vwap_len = vwap_len
        self._atr_len = atr_len
        self._stretch = Decimal(str(stretch_atr))
        self._stop_buf = Decimal(str(stop_buf_atr))
        self._tcap = Decimal(str(target_cap_atr))
        self._rv = recent_vol_len
        self._decl = decline_len
        self._min_bars = min_bars

    def scan(self, ticker: str, bars: list[Bar]) -> Candidate | None:
        n = self._vwap_len
        if len(bars) < max(self._min_bars, n + self._atr_len + 2, self._decl + 2):
            return None
        cur = bars[-1]
        if cur.close <= cur.open:
            return None

        window = bars[-n:]
        pv = Decimal("0")
        vol_sum = Decimal("0")
        for b in window:
            v = Decimal(str(b.volume))
            tp = (b.high + b.low + b.close) / Decimal("3")
            pv += tp * v
            vol_sum += v
        if vol_sum <= 0:
            return None
        vwap = pv / vol_sum

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

        entry = cur.close
        if entry >= vwap - self._stretch * a:
            return None

        # Decline: close lower than N bars ago
        if entry >= bars[-(self._decl + 1)].close:
            return None

        # Rising volume into the decline: recent avg volume > earlier part of window
        recent = [Decimal(str(b.volume)) for b in window[-self._rv:]]
        earlier = [Decimal(str(b.volume)) for b in window[:-self._rv]]
        if not earlier:
            return None
        recent_avg = sum(recent) / Decimal(len(recent))
        earlier_avg = sum(earlier) / Decimal(len(earlier))
        if earlier_avg <= 0 or recent_avg <= earlier_avg:
            return None

        stop = min(b.low for b in bars[-3:]) - self._stop_buf * a
        if stop <= 0 or stop >= entry:
            return None
        target = min(vwap, entry + self._tcap * a)
        if target <= entry:
            return None
        risk = entry - stop
        rr = (target - entry) / risk
        if rr < Decimal("1.5"):
            return None

        # Score components
        dist_atr = float((vwap - entry) / a)
        stretch_score = min(35, max(0, int((dist_atr - float(self._stretch)) * 20)))
        vol_ratio = float(recent_avg / earlier_avg)
        vol_score = min(25, max(0, int((vol_ratio - 1.0) * 40)))
        avg20 = vol_sum / Decimal(n)
        today_ratio = float(Decimal(str(cur.volume)) / avg20) if avg20 > 0 else 0.0
        absorb_score = min(20, max(0, int((today_ratio - 0.8) * 20)))
        rng = cur.high - cur.low
        close_pos = float((cur.close - cur.low) / rng) if rng > 0 else 0.5
        close_score = min(20, max(0, int(close_pos * 20)))
        strength = max(0, min(100, stretch_score + vol_score + absorb_score + close_score))

        sma20 = sma([b.close for b in bars], n)
        gap_txt = ""
        if sma20 is not None and sma20 > 0:
            gap = (float(vwap) - float(sma20)) / float(a)
            gap_txt = f" VWAP-SMA20 gap {gap:+.2f} ATR."

        return Candidate(
            ticker=ticker,
            side="buy",
            entry=entry,
            stop=stop,
            target=target,
            risk_reward_ratio=rr.quantize(Decimal("0.01")),
            signal_strength=strength,
            thesis=(f"Closed {dist_atr:.2f} ATR below 20-day VWAP {vwap:.2f} after a decline on rising volume "
                    f"(recent/earlier vol {vol_ratio:.2f}x) with a green bar; VWAP-benchmarked buyers "
                    f"should absorb supply and pull price toward VWAP.{gap_txt}"),
        )

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
Buy a close 2.5 ATR under 20-day VWAP, up-bar, VWAP target: Loses money · EdgeProven