Tools · 6 min read
Backtest Framework for Silver (XAG)
Build and run a rigorous backtest framework for Silver (XAG). Test entry rules, volatility filters, and position sizing against historical XAG price data.
Silver (XAG) has delivered intraday swings exceeding 4% on more than 60 trading days in the past three years — a volatility profile that punishes untested strategies and rewards systematic preparation. Unlike equity indices, XAG reacts to a compound set of drivers: industrial demand signals, gold-to-silver ratio shifts, USD strength, and speculative futures positioning reported weekly in the CFTC COT data. Any backtest framework that ignores these layers is testing a different asset than the one you are actually trading.
The stakes are concrete. A silver breakout strategy that looked profitable in 2020’s supply-shock rally collapses in a mean-reverting, range-bound 2022 environment. Without a structured backtest framework, you cannot separate genuine edge from regime-specific luck. Most retail backtests on XAG fail at two points: they use closing prices that misrepresent intraday execution, and they never stress-test against the metal’s periodic liquidity gaps around macro events.
This page walks through a complete backtest framework for Silver — from data sourcing and signal design to risk-adjusted performance metrics and prompt templates you can run directly in Assistly’s backtester. The workflow is XAG-specific, not a generic commodity template.
Why Silver Demands Its Own Backtest Logic
Silver occupies a structural middle ground between monetary metal and industrial input. Roughly 50% of annual silver demand is industrial — solar panels, electronics, EV components — which anchors XAG to manufacturing PMI data and supply chain conditions in a way gold never is. This dual-use characteristic creates regime breaks that a single backtested strategy rarely survives intact.
The gold-to-silver ratio (GSR) is the most actionable structural signal specific to XAG. When the GSR compresses below 70, silver is in a risk-on, industrial-demand-driven phase; above 90, it behaves more defensively and correlates tightly with gold. Your backtest framework must segment data by GSR regime — otherwise you are averaging together two fundamentally different assets.
Liquidity is the third dimension. XAG spot and futures markets thin out significantly outside London and New York session overlaps. Backtests using daily bars miss the fact that many silver moves initiate in thin Asian hours and reverse before the close. Use hourly bars at minimum, and flag entries that would have occurred in the 21:00–01:00 UTC window as requiring a liquidity haircut.
- Segment backtest data by gold-to-silver ratio regime (below 70, 70–90, above 90)
- Use hourly or 30-minute bars — daily bars obscure XAG’s intraday reversal patterns
- Incorporate CFTC COT net speculative positioning as a weekly regime filter
- Apply a liquidity flag for entries during Asian thin-market hours
- Account for widened spreads around FOMC, NFP, and CPI releases
Defining Your Silver Signal Architecture
A robust XAG signal starts with a clear thesis. Two strategies have shown durable edge in peer-reviewed commodity research: momentum breakouts above 20-day highs (strongest in GSR-compression regimes) and mean reversion from Bollinger Band extremes (strongest when GSR is elevated and speculative positioning is stretched). Do not mix both into one backtest — test each hypothesis separately before considering a combined approach.
For the breakout variant, define entry as a close above the 20-day high with above-average volume on the XAG futures contract (SI on CME). Exit rules matter as much as entry: a trailing stop of 1.5× ATR(14) has historically preserved more upside on silver’s explosive moves than fixed-percentage exits, because XAG trends tend to extend beyond conventional profit targets before reversing.
For the mean-reversion variant, entry triggers when XAG closes more than 2.0 standard deviations below its 20-day mean and the 14-day RSI is below 28. The critical filter: exclude entries when the broader commodity complex (DJP or BCOM index) is in a confirmed downtrend — isolated silver weakness in a commodity bear market is not a reversion setup, it is continuation.
You are a quantitative analyst backtesting a Silver (XAG) mean-reversion strategy. Data: hourly XAG/USD bars, January 2019 to December 2024. Entry rule: price closes more than 2.0 standard deviations below 20-period mean; RSI(14) < 28. Filter: exclude entries when BCOM index 50-day SMA slope is negative. Exit: price returns to 20-period mean OR stop-loss at 1.8× ATR(14) below entry. Position size: risk 1% of equity per trade. Report: total trades, win rate, average R-multiple, max drawdown, Sharpe ratio, and breakdown by gold-to-silver ratio regime (below 70, 70–90, above 90).
Data Requirements and Preparation for XAG Backtests
Use CME Group’s SI (Silver Futures) front-month contract as your primary price series, not spot XAG feeds from retail brokers. SI data is cleaner, includes volume, and reflects institutional execution prices. Roll the contract on the first business day of the delivery month to avoid distortions from thin expiry-week trading. Continuous adjusted series are available from Norgate Data and Quandl’s CHRIS dataset.
Supplement price data with three external series: weekly CFTC COT non-commercial net positioning (available every Friday), the gold-to-silver ratio calculated from front-month futures, and the DXY index as a USD strength filter. All three should be merged into your backtest dataset at the weekly frequency and forward-filled to daily or hourly bars. Missing this step means your signals are firing without awareness of the macro context that drives roughly 40% of XAG’s directional variance.
Clean the data for roll gaps, holiday sessions, and the March 2020 liquidity event where silver dropped 35% in eleven days before recovering. That event is a legitimate stress-test scenario — do not remove it. Flag it as a tail-risk observation and examine whether your stop-loss rules would have survived it without catastrophic drawdown.
SILVER BACKTESTER
Assistly's backtesting tool lets you test XAG strategies against historical data with ATR-based position sizing, regime filters, and full trade-level reporting — no spreadsheet required.
Risk and Position Sizing in a Silver Backtest
Silver’s ATR(14) on the daily chart averaged $0.68/oz in 2021 and spiked to $1.24/oz during the January 2021 retail-driven squeeze. A fixed 2% stop-loss in dollar terms means wildly different position sizes across volatility regimes. The correct approach is ATR-based position sizing: risk a fixed percentage of equity (1–2%) divided by the entry-day ATR multiplied by your stop multiple. This dynamically shrinks exposure when XAG is volatile and expands it when it is coiling.
Correlation with gold matters for portfolio-level backtests. XAG and XAU carry a 90-day rolling correlation that typically sits between 0.75 and 0.92. If you are running simultaneous silver and gold positions, your effective single-metal exposure is larger than the nominal position sizes suggest. Your backtest framework should calculate portfolio-level metal exposure and cap it — a common rule is no more than 8% of equity in correlated precious metal positions combined.
Slippage modeling is non-negotiable for XAG. Assume 0.03–0.05% slippage per side for futures during normal sessions and 0.10–0.15% during macro event windows. Run your backtest with and without slippage assumptions and report both sets of results — the gap between the two is your execution risk budget.
Analyze position sizing for a Silver (XAG) breakout strategy with ATR-based risk management. Assumptions: $100,000 portfolio, 1.5% risk per trade, stop-loss at 2× ATR(14) below entry. Calculate: position size in oz for three scenarios — ATR = $0.50, ATR = $0.90, ATR = $1.40. Also calculate: maximum concurrent silver positions before hitting an 8% portfolio metal exposure cap. Assume current XAG price = $29.50/oz. Show all calculations step by step.
Interpreting Backtest Results for XAG Strategies
A Sharpe ratio above 1.0 on a silver backtest is meaningful only if it holds across all three GSR regimes. A strategy that posts a Sharpe of 1.8 in GSR-compression periods but -0.4 in GSR-elevated periods is a regime-dependent bet, not a systematic edge. Present regime-segmented Sharpe and max drawdown figures as your primary performance table, not the aggregate number.
Profit factor (gross profit divided by gross loss) is the most intuitive metric for XAG strategies. A profit factor above 1.5 with more than 150 trades is a credible threshold. Below 100 trades, any result — good or bad — is statistically insufficient to draw conclusions about silver specifically, given its tendency for multi-month trending periods that compress independent trade observations.
Walk-forward testing is mandatory. Split your XAG data into 60% in-sample (optimize parameters) and 40% out-of-sample (validate). If your strategy’s out-of-sample Sharpe is less than 60% of its in-sample Sharpe, you have overfitted to silver’s historical quirks rather than identified genuine edge.
- Report Sharpe ratio and max drawdown by GSR regime — not just aggregate
- Require profit factor above 1.5 with 150+ trades before trusting results
- Run walk-forward: out-of-sample Sharpe should be at least 60% of in-sample
- Compare slippage-included vs. slippage-excluded results to size execution risk
- Stress-test against March 2020 and January 2021 as named tail-risk events
Building the Framework Iteratively in Assistly
Start with a single, clean hypothesis — not a multi-condition system. Paste your XAG price data or connect via the supported data integrations, define one entry rule and one exit rule, and run the base case. Assistly’s backtester will return trade-level logs, equity curve, and summary statistics. Your first iteration is diagnostic, not final — you are looking for the shape of the edge, not the optimized parameter set.
Add filters incrementally. Introduce the GSR regime filter, re-run, and compare the filtered vs. unfiltered results side by side. Then add the COT positioning filter. Each addition should be justified by a prior hypothesis, not by searching for whatever improves the Sharpe. This discipline is what separates a backtest framework from a curve-fitting exercise on XAG’s historical accidents.
Document every parameter change and the rationale behind it. Silver strategies fail in live trading most often because the trader cannot explain why each rule exists and therefore abandons the system the first time it underperforms. A well-documented XAG backtest framework is also a live-trading rulebook.