Band-grid strategy on BTC/USD 5-minute — the strategy, the method, the results

A TradingView Pine v6 strategy — a 7-band standard-deviation grid of chained limit orders with martingale sizing and an SMA-basis exit — ported to the QuantConnect LEAN engine and tested on 5.5 years of Alpaca BTC/USD minute data. The headline experiment is the one you'd actually run: every period, re-optimize on the trailing month and trade the winning parameter set forward (weekly and monthly cadence), out-of-sample over 2025-01 → 2026-06 — a window in which BTC itself fell 37%.

LEAN v2.5 · net10.0 · local source build Data: Alpaca crypto API · minute bars 2021-01 → 2026-07 Fees: Alpaca tier-0 · 15 bps maker / 25 bps taker IS 2021-02 → 2024-12 · OOS 2025-01 → 2026-06 314 IS trials · 95 walk-forward folds

Study outcome: KILL (follow-up verification, 2026-07-04)

The walk-forward result below survived two kill experiments — and then failed the decisive one: the edge does not exist in the prints of any venue where the strategy can actually be executed. Re-run on Binance's own BTCUSDT minute data (the only wired venue that permits shorting), every profitable window inverts to a loss. The profit measured on Alpaca/Coinbase prints was thin-venue wick noise: those bars have ~35–40% wider minute ranges, and half of the grid's limit-order fills never print on the deep venue. Details and the estimated return on investment are in the follow-up section.

How the strategy works — real fills from the backtest

15 real hours of the LEAN backtest (Pine-default parameters, Jan 2–3 2025). Price walks down through the lower bands: each band it touches fills a resting limit buy ~1.5× larger than the last; the whole stack exits the moment price recovers to the moving-average basis. Dot size = order size.

The rules (as in the Pine script)

  • Basis & bands. SMA(hl2, length) ± multk · stdev · ext, 7 bands each side (mults 0.3 → 10.47).
  • Entry grid. Flat: one resting limit at band 1 (long below / short above, if filters allow). In a position: resting limits at bands 2–7, each scaleFactor (1.5×) bigger — a martingale.
  • Exit. Every entry exits at the same price: the current basis. One winning touch of the mean closes the whole stack.
  • Filters (first entry only): Kaufman efficiency ratio > threshold, and a daily-trend gate — longs only above the daily SMA, shorts only below.
  • Sizing. Band 1 = basePct% of equity, locked while the position is open.

Why it wins and loses

  • Chop around a flat/rising basis → many small wins (the grid buys dips, sells the mean).
  • A trend away from the basis → the martingale stacks up losers and the basis-exit recedes — the loss profile is rare but large. Win-rate ≈ 74%, avg win $11 vs avg loss $52 at defaults.

What was tested, and how

Faithful port to LEANPine v6 → C# QCAlgorithm: chained limit grid, quantity locking, aggregate basis exit, ER/MTF gating, trailing-stop variant. Fills evaluate on the minute stream (finer than Pine's per-bar OHLC); Alpaca tier-0 maker/taker fees modeled on every fill.
Adversarial verificationA 3-lens multi-agent review (Pine fidelity · LEAN engine semantics · experiment math) surfaced 7 confirmed defects — including a backtest-only lookahead in order updates, stale first-band sizing, a 1-day walk-forward fold overlap, and sub-lot-size dust bricking the state machine. All fixed; every result below is from the corrected engine.
In-sample exploration — 314 runsBroad grid (length × band-width × sizing × filters) on a bull and a bear half-year, a user-requested wide-band region (L25–70, ext 6–12), filter/threshold refinement, long-only variants, zero-fee diagnostics, and 16 full 4-year runs. OOS 2025+ never touched.
Candidate menu — 10 configsChosen on IS evidence only, deliberately spanning defensive (wide bands, long-only) → aggressive (L400 × 2) → shorts-capable/unfiltered → the Pine defaults as a control.
Walk-forward out-of-sample — 95 foldsFor each fold: backtest all 10 candidates on the trailing calendar month, pick the winner (by P&L; by Sharpe; and Sharpe-or-stay-flat), trade it for the next month (18 folds) or week (77 folds). Compared against fixed-config baselines and BTC buy & hold.
Verdict — MIXED, registeredWalk-forward is the only positive variant (+13.7…+15.1%) but the profit is concentrated in one regime event; 7 append-only records in the backtest registry document every number.

The data & the split

BTC/USD 2021 → mid-2026 covers four regimes. Everything before 2025 was fair game for optimization; 2025-01 → 2026-06 was locked away for the walk-forward only.

Out-of-sample equity — walk-forward vs fixed configs vs BTC

Indexed to 100 on 2025-01-01. Walk-forward curves are stitched from per-fold LEAN backtests (each fold trades the config that won the trailing month, P&L rule). Fixed configs hold one parameter set throughout.

Table view (month-end index values)

What the optimizer picked, fold by fold

Bars: out-of-sample return of each fold (%). Strip below: which candidate won the trailing month and traded that fold. The 2026 gains come from folds where the optimizer switched to the shorts-capable, unfiltered config (agg-bs-noMTF) during the crash — a config that was mediocre in-sample.

Monthly folds — optimize 1 month, hold 1 month

Weekly folds — optimize 1 month, hold 7 days

Table view (all folds)

Why no fixed config survives: the parameter landscape

Best 6-month net P&L (%) achievable in each SMA-length × band-width cell (best across sizing and filter variants) — bull half-year vs bear half-year. Blue = profit, red = loss. 0 of 108 configurations were positive in both regimes: the strategy's sign flips with the market, which is exactly what the walk-forward layer exploits — and why any single "optimized" setting is fragile.

Bull window · 2024-01 → 2024-06

Bear window · 2022-07 → 2022-12

Full in-sample ranking (2021-02 → 2024-12) & the fee question

The 4-year in-sample runs. The as-published Pine defaults lose −91.8% (21,891 trades, ~$85k of fees on $100k — TradingView's default backtest charges zero commission, which is why it looks fine on-platform). But fees are not the whole story: the zero-fee diagnostic still loses in bear windows — a long martingale grid under a falling basis is structurally unprofitable.

Zero-fee diagnostic (same cells, 0 bps)

Follow-up: independent review, kill experiments & the venue replication that ended it

An independent quant review found the walk-forward wrapper adds no selection skill (always-on agg-bs-noMTF beat the 10-candidate optimizer: +15.4% vs +14.7% over the same months), and that the config is an intermittent-regime harvester, not a crash harvester: all in-sample profit sits in 4 months of 47 (−10.1% excluding them). It pre-registered kill experiments; here is the complete scorecard.

Kill experiments on the original (thin-venue) prints — both survived

ExperimentWindowFees (mk/tk bps)Net P&LSharpeMax DDVerdict
Mechanism on full history2021-02 → 2024-1215 / 25+82.8%0.6423.4%survives (but: 1-of-5 stress events harvested; profit in 4 of 47 months)
Cost-stress, crash window2025-11-17 → 2026-04-1315 / 25+21.2%4.982.3%survives +20 bps
25 / 35+15.0%3.402.3%
35 / 45+9.0%1.792.6%

The decisive test: same strategy, Binance's own prints, Binance's real fees

Binance BTCUSDT minute klines 2021→2026 were downloaded and quality-checked (closes track Coinbase within 2–7 bps on average — same asset, same path). The pre-registered bar: both profitable regimes must reproduce at ≥50% magnitude, full-span Sharpe ≥ 0.6 and CAGR ≥ 10%, off-regime bleed ≤ 5%/yr.

WindowThin-venue prints (Coinbase/Alpaca)Binance prints, perps fees (2/4.5 bps)Kill barResult
ON regime 1 · Feb 23 → Mar 24+156%−5.4%≥ +75%FAIL
ON regime 2 · Nov 25 → Apr 26+21.6%−3.2%≥ +10%FAIL
Full span 2021-02 → 2026-06≈ +100% (est.)−22.0% (CAGR −4.5%, Sharpe −1.71, DD 22.5%)Sharpe ≥ 0.6, CAGR ≥ 10%FAIL
OFF-regime bleed−7…−11%/yr−4…−6%/yr≤ 5%/yrFAIL

Why: Alpaca/Coinbase minute bars carry ~35–40% wider high-low ranges than Binance (11.7–14.4 bps vs 7.7–10.5 bps average). The band-grid's limit fills live in exactly those extra wicks — on Binance, trade count drops ~55% and the surviving fills are adversely selected. Cheaper fees can't rescue fills that never happen. Funding, for the record, was measured and is negligible (+0.02% of equity over the crash window); it was never the problem.

Estimated return on investment

Estimates anchor on the backtests above; "executable" means a venue where the required side (shorts) can actually trade. Estimates, not promises — and the honest estimate is negative.

Deployment pathExecutable?Est. annual ROIEst. max drawdownOn $100k / year
Binance USDT-M perps or cross-margin, always-on (full-span replication)yes (shorts OK)≈ −4.5%/yr~22%≈ −$4,500
Binance, crash-regime only (best observed window)yes−3…−5% per regime~5%negative
Alpaca spot, long-only fixed IS-winneryes (no shorts needed)≈ −0.8%/yr~2%≈ −$800
Walk-forward paper number (thin-venue prints, needs shorts)no+9.1%/yr (Sharpe 1.5) — unrealizable~2%n/a: fills don't exist on an executable venue

Bottom line: no tested configuration has a positive expected ROI on any venue where it can actually be executed. Registry verdict: KILL. The reusable outputs of this study are the infrastructure (Binance connector with spot/margin/futures modes, minute + funding data pipelines, the corrected anti-lookahead grid engine) and the method lesson: always replicate a microstructure edge on the execution venue's own prints before believing it.

Read this before trading it

Profit concentration. Nearly all walk-forward gains come from four consecutive crash months (Dec 2025 – Mar 2026) when the optimizer latched onto the short grid. One regime event, not a repeated harvest. Fold hit-rate is 28% (monthly) / 38% (weekly): many small losses, few large wins.
Sample size. 18 monthly / 77 weekly folds ≈ 1.5 years out-of-sample. Sharpe 1.2–1.5 over that span is suggestive, not conclusive. Registry verdict: MIXED, not PASS.
Venue reality. Alpaca spot crypto cannot short. The bear-market profit engine requires a margin or perps venue; on Alpaca as-is, the long-only menu would have kept the walk-forward roughly flat through the bear rather than profitable.
Selection layers. The 10-candidate menu came from 314 in-sample trials. The walk-forward itself is leak-free (each fold sees only its trailing month), and the star pick was not an in-sample winner — but menu design remains a researcher degree of freedom.
Execution model. Resting limit orders, minute-resolution fills, maker 15 bps, anti-lookahead order updates, lot-size rounding. Live slippage and queue position are still un-modeled.

Generated 2026-07-04 · LEAN v2.5 (local source build) · data: Alpaca crypto bars API · artifacts & registry records: randomKnap/lean-strategy (backtests/BandGrid5m/, backtests/registry/BandGridSmaExit__*)