← Experiments

S&P 500 breadth low Pine HMA20 8.5/0 fidelity re-audit

Rejected qm-kdnj.1 · 2026-08-18

Does the Pine-verbatim S&P 500 breadth low HMA20 8.5/0 crossover/crossunder (request.security D close, ta.hma WMA steps, ta.crossover prev<=8.5 & curr>8.5, ta.crossunder prev>=0 & curr<0) reproduce signal dates tick-for-tick and does the corrected signal predict capitulation recovery beyond generic defensive on maximal native span?

Pine semantics frozen and tick-for-tick correct (HMA20=WMA(2*WMA10-WMA20,4) sparse buy impulse, 19 triggers native vs 18 SPY-aligned due to 2008-11-27 Thanksgiving bar shift and Jan28 HMA drift from holiday gap — 10.5% calendar delta not definition bug; evaluator vs direct delta 0, mega crossunder independent from low crossover, no off-by-one/lookahead/ffill/EMA-seed, pinned fixture logic verified). Re-audit on maximal native 2006-12-29→2026-08-11 and SPY-aligned 2007-01-01→2026-08-04 shows prior qm-4bx.18/23 already Pine-correct for execution (18 triggers 224 active hw20 4.68%); native Pine truth is 19 triggers 239 active 4.82% including Thanksgiving-bar. Signal is sparse buy-only (0.92/yr native) not persistent regime. Walk-forward both halves +29%/+33%, falsification passes (random 0 trig =base, inverted 0 trig 4.66), extra lag -2.6% not destructive, generic-exit harness +73% vs SMA200 but 0% vs B&H and brittle (HMA-only, mega 1 drops to 5.79, holding 60d 12.58 dominates).

Research narrative

Generic opposite-signal harness

S&P 500 breadth low HMA20 8.5/0 Pine buy impulse (ta.hma WMA(2*WMA10-WMA20,4), ta.crossover prev<=8.5 & curr>8.5, ta.crossunder prev>=0 & curr<0, OR independent, hw20 fixed, 18 triggers SPY-aligned 224 active 4.55%) blended with generic defensive via OR override (long if either generic long or signal active) — each head-to-head generic-only vs signal+generic on same window/costs/lag via BacktestConfig.allocatesmartly() next_close 10bps; deltas SMA50 76.3% (CAGR +3.07% Sharpe +0.14 MaxDD +8.22% hit 198/false 26), SMA200 72.8% (CAGR +3.09% Sharpe +0.07 MaxDD -2.09% hit 204/false 20), cross 44.9% (CAGR +2.09% Sharpe +0.05 MaxDD -0.00% hit 179/false 45), trailing10 80.4% (CAGR +3.29% Sharpe +0.10 MaxDD -0.64% hit 186/false 38), trailing15 73.7% (CAGR +3.05% Sharpe +0.12 MaxDD +4.04% hit 160/false 64), trailing20 59.0% (CAGR +2.60% Sharpe +0.09 MaxDD +6.72% hit 110/false 114), trailingATR3x 61.5% (CAGR +2.51% Sharpe +0.20 MaxDD -2.35% hit 224/false 0), trailingVol2x 61.5% (CAGR +2.48% Sharpe +0.26 MaxDD -1.07% hit 224/false 0), BH 0.0% (CAGR +0.00% Sharpe +0.00 MaxDD +0.00% hit 0/false 224) — window 2007-01-03→2026-07-24 same window/costs/lag next_close +10bps L20 S5FI 4956/224 active 4.55% tradingview close_only offline

Generic opposite-signal harness (Δ head-to-head)

Window: 2007-01-03→2026-07-24 same window/costs/lag next_close +10bps — same window/costs/lag via BacktestConfig.allocatesmartly() next_close 10bps

GenericGeneric-onlySignal+GenericΔ%ΔCAGRΔSharpe
sma502.22693.926576.32%+3.07%+0.14
sma2005.12628.857772.79%+3.09%+0.07
cross_50_2005.30757.692344.93%+2.09%+0.05
trailing_10pct3.99917.214280.40%+3.29%+0.10
trailing_15pct3.31435.755573.65%+3.05%+0.12
trailing_20pct4.42887.043059.03%+2.60%+0.09
trailing_atr1.16281.878561.54%+2.51%+0.20
trailing_vol0.97741.578961.54%+2.48%+0.26
bh7.47017.47010.00%+0.00%+0.00

S&P 500 breadth low HMA20 8.5/0 buy impulse (Pine ta.hma WMA steps ta.crossover/crossunder, hw20 fixed) paired with generic opposite SPX <50DMA, <200DMA, 50/200 death-cross, trailing-stop 10/15/20% via backtest/generic_signals.py — each head-to-head generic-only vs signal+generic on same window/costs/lag via BacktestConfig.allocatesmartly() next_close 10bps, offline ensure_ohlcv offline=True, INDEX:S5FI 4956 rows 2006-12-29..2026-08-11 tradingview

S&P 500 breadth low HMA20 8.5/0 Pine buy impulse (ta.hma WMA(2*WMA10-WMA20,4), ta.crossover prev<=8.5 & curr>8.5, ta.crossunder prev>=0 & curr<0, OR independent, hw20 fixed, 18 triggers SPY-aligned 224 active 4.55%) blended with generic defensive via OR override (long if either generic long or signal active) — each head-to-head generic-only vs signal+generic on same window/costs/lag via BacktestConfig.allocatesmartly() next_close 10bps; deltas SMA50 76.3% (CAGR +3.07% Sharpe +0.14 MaxDD +8.22% hit 198/false 26), SMA200 72.8% (CAGR +3.09% Sharpe +0.07 MaxDD -2.09% hit 204/false 20), cross 44.9% (CAGR +2.09% Sharpe +0.05 MaxDD -0.00% hit 179/false 45), trailing10 80.4% (CAGR +3.29% Sharpe +0.10 MaxDD -0.64% hit 186/false 38), trailing15 73.7% (CAGR +3.05% Sharpe +0.12 MaxDD +4.04% hit 160/false 64), trailing20 59.0% (CAGR +2.60% Sharpe +0.09 MaxDD +6.72% hit 110/false 114), trailingATR3x 61.5% (CAGR +2.51% Sharpe +0.20 MaxDD -2.35% hit 224/false 0), trailingVol2x 61.5% (CAGR +2.48% Sharpe +0.26 MaxDD -1.07% hit 224/false 0), BH 0.0% (CAGR +0.00% Sharpe +0.00 MaxDD +0.00% hit 0/false 224) — window 2007-01-03→2026-07-24 same window/costs/lag next_close +10bps L20 S5FI 4956/224 active 4.55% tradingview close_only offline

Equity vs S&P (aligned, rebased to 1.0)

No signal overlay for this experiment (parameter sweep / search)

Aligned window, both rebased to 1.0 at start — Aligned window, both rebased to 1.0 at start for fair comparison · S&P dashed, experiment solid. X = Date, Y = Equity (rebased to 1.0).

Signal driver & thresholds (x-aligned)

Signal timeline (sparse triggers)

Triggers when overlay takes over base strategy

Signal timeline — triggers shown as verticals on main chart above.

Stats

CAGR0.00%Sharpe0.00%
Sortino0.00%maxDD0.00%

Disposition

Rejected for risk-off-indicators/v1 and strategy promotion — fidelity verified (Pine-native 19 vs SPY 18, delta 2 calendar-driven, no HMA/crossover bug; prior already correct for execution) but brittle/optimization risk and sparse power; publish as qm-kdnj experiment with frozen Pine semantics, parity metrics, and generic-exit harness. Retain as risk-signals/v1 SHIP as signal (buy-signals-v1.json s5fi-breadth, signals/history.json, docs/signals.html).

Follow-on work

Errors & data gaps

Native INDEX:S5FI 2006-12-29→2026-08-11 4956 rows TradingView daily; SPY-aligned 18 triggers loses Thanksgiving 2008-11-27 bar vs native 19 (HMA drift on holiday gap) — Pine native 19 is documentation truth, execution 18 is tradeable; pre-2006 insufficient_history without licensed 500-stock constituent history — no synthetic invented beyond ETF proxy 1999-03-05 (9 sector SPDRs, 0.93 corr but weaker 5.88 vs 8.01) Only HMA20 works (SMA/EMA/WMA/Wilder collapse to base ~4.5) — HMA dependence disclosed, not repaired; mega 0 brittle (±1 drops 2.2 to 5.79) and low10 9.55 narrowly beats 8.5 — threshold plateau not lone optimum Holding window monotonic 60d 12.58 dominates 20d 8.01 — optimization risk; 20 frozen per best-practice not 60; decay/retrigger boolean identical to fixed for sparse; consensus overlay 0 vs SMA200 (needs base bullish) fails SPY B&H zero marginal (already max long) — rescue-only for defensive bases (+73% vs SMA200, +10.9% vs 60/40); 0.92/yr sparse limited power despite 19y span; ensemble 5/8.5/10 voting could reduce brittleness but not blended DB 100M near 95MB soft limit but under 100M hard; sidecar data/sim_daily.sqlite not used for S5FI; closed market holidays (Thanksgiving) cause 10.5% native vs execution date divergence — documented not a signal bug Extra lag +1 bar -2.6% small drag, still > base; walk-forward both halves positive but with window optimization risk; need frozen holding/overlay pre-registered OOS 36 Deflated Sharpe before admission

Follow-up

gh issue create --title "Follow-up SP 500 breadth low Pine HMA20 850 fidelity re-audit" --body "Follow-up to qm-kdnj.1: Does the Pine-verbatim S&P 500 breadth low HMA20 8.5/0 crossover/crossunder (req" --label "priority:p2" --label "pipeline:research" --label "agent:ready"
# deep-link