Noon Barbari
Registrati
Tutti gli articoli
tutorialPubblicato ·8 min di lettura

How to backtest a VWAP strategy on crypto (filter, not trigger)

VWAP is a fair-value benchmark, so the strategies worth backtesting use it as a filter or a reversion reference — not a crossover signal. Here's how to test one honestly.

In questa pagina

VWAP — the volume-weighted average price — is a benchmark of fair value, not a momentum signal. That single fact decides how you should backtest it. "Buy when price crosses above VWAP" backtests like any other crossover: it whipsaws in chop and gives back its edge to costs. The strategies actually worth testing use VWAP as a *filter* on a directional idea, or as the centre line of a *reversion* setup. This walkthrough builds and validates one of each.

Step 1: pick a role for VWAP, then write complete rules

VWAP works two ways in a rule set. As a trend filter: only take long entries while price is above a rising VWAP, so your directional strategy is gated to the side institutions are leaning. As a reversion reference: when price stretches a long way above or below VWAP — measured by standard-deviation bands around it — fade the move back toward fair value, but only in a ranging market.

BTC/USDT 1h price with anchored VWAP and ±1σ / ±2σ bands; price oscillates inside the bands and tags the outer band before reverting toward VWAP.
VWAP with ±1σ and ±2σ bands. A tag of the outer band is 'stretched' relative to the session's volume-weighted fair value.

The chart shows VWAP with one- and two-sigma bands. A tag of the ±2σ band means price is stretched far from the volume-weighted consensus — the raw material of a reversion trade. But notice that price can *ride* the band in a strong move, which is exactly why a reversion rule needs a regime filter: fade the bands only when the market is ranging, never in a trend.

Step 2: get clean, session-aware data

Pull real OHLCV for your symbol, timeframe, and exchange. VWAP is volume-weighted, so your data's volume column has to be trustworthy — a feed with bad or missing volume produces a garbage VWAP. Decide, too, whether you want a session-resetting VWAP (the intraday default) or an anchored one; the rule you test must match the line you'd actually trade.

Step 3: run it and read the right metrics

A VWAP *filter* should be judged on whether it improves a base strategy — run the strategy with and without the filter and compare Sharpe, maximum drawdown, and trade count. If the filter only trims trades without lifting risk-adjusted return, it isn't earning its place. A VWAP *reversion* rule typically has a high win rate and small wins, so watch the average loss — one un-stopped reversion trade in a trend can erase a month of winners.

rules.yaml — VWAP as a trend filter on a momentum entry
strategy:
  name: vwap_filtered_momentum
  indicators:
    - { id: vwap, kind: VWAP }
    - { id: ema_fast, kind: EMA, period: 9 }
    - { id: ema_slow, kind: EMA, period: 21 }
  rules:
    entry:
      all:
        - { type: crosses_above, left: ema_fast, right: ema_slow }
        - { type: above, left: close, right: vwap }   # only long above fair value
    exit:
      any:
        - { type: crosses_below, left: ema_fast, right: ema_slow }
  risk:
    size_pct: 0.5
    stop_loss_atr: 2.0

Step 4: walk-forward it

Whether VWAP genuinely helps is an empirical question, and the honest way to answer it is walk-forward. Tune the base strategy and the band width on an in-sample window, then test on the next, unseen window with the VWAP rule attached. If "price above VWAP" only improved the numbers because it happened to dodge a couple of bad trades in your history, walk-forward exposes it. If the fair-value context lifts out-of-sample performance, you've found a real filter — see why your live trading underperforms your backtest for why that out-of-sample check matters so much.

Do it in Noon Barbari

VWAP is built in, and a price-vs-VWAP condition drops straight into the visual strategy designer as a filter on any directional rule. Backtest the base strategy with and without it, then walk-forward to confirm the fair-value context is a real edge and not a flattering coincidence. Use VWAP for what it is — a benchmark of fair value — and it earns its keep; trade its crossover and it joins the pile of signals that look good until you test them.

Provalo con i tuoi dati

Ogni concetto visto sopra è implementato nella piattaforma. Backtest, walk-forward, paper trading, poi passa al live — stesso set di regole in ogni fase.

Letture correlate

Guide correlate

Termini chiave