Statistical Arbitrage Strategy
ZSCORE, RSI, ATR, SMA, EMA
Z-Score Statistical Arbitrage: Mathematical Game of Gold-Silver Ratio
This isn't your typical trend-following strategy. The XAG/XAU statistical arbitrage strategy operates on a core assumption: gold and silver prices maintain a long-term mean-reverting relationship. When Z-Score breaks beyond ±2 standard deviations, price deviation reaches statistical significance, providing entry opportunities for reversion trades. Backtesting data shows this statistical arbitrage approach delivers superior risk-adjusted returns in precious metals markets.
20-Period Normalized Ratio: More Precise Than Traditional Correlation Analysis
The strategy's core builds a normalized price ratio model. Using 20-period SMA to standardize XAG and XAU separately, then calculating the ratio smoothed with 3-period EMA. This approach proves more stable than simple price ratios, effectively filtering short-term noise. When the normalized ratio's Z-Score exceeds ±2 boundaries, it indicates current prices deviate from historical mean by over 2 standard deviations—statistically a low-probability event, providing mean reversion entry timing.
RSI Filter: Clever Use of the 50 Midline
Unlike traditional RSI overbought/oversold signals, this uses RSI=50 as long/short filter condition. RSI<50 allows long positions, RSI>50 allows short positions. The logic is clear: buy during relative weakness expecting bounce, sell during relative strength expecting pullback. This filtering mechanism effectively reduces counter-trend trading risks and improves signal quality.
3:8 ATR Risk-Reward Ratio: Positive Mathematical Expectation
Take profit set at 3x ATR, stop loss at 8x ATR, achieving 1:2.67 risk-reward ratio. This design leverages statistical arbitrage characteristics: mean reversion probability is relatively high, but requires sufficient tolerance space. 14-period ATR ensures stop/target levels adapt to market volatility changes. Historical backtests show this ratio achieves positive expected returns in precious metals pair trading.
Applicable Scenarios: Ranging Markets Outperform Trending Markets
Statistical arbitrage strategies perform best in sideways choppy conditions, where mean reversion characteristics are more pronounced. In strong trending markets, prices may deviate from mean for extended periods, causing significant drawdown risks. Recommended use during moderate volatility periods without obvious directional bias. Note that precious metals markets are heavily influenced by macroeconomic factors—exercise caution during major event periods.
Risk Warning: Statistical Model Limitations
Historical statistical relationships don't guarantee future continuation. Gold-silver ratios may experience long-term shifts due to supply-demand structural changes, monetary policy differences, and other factors. Strategy faces consecutive loss risks, particularly during market structural change periods. Recommend strict risk management, limiting single trade risk to no more than 2% of account capital, and regularly evaluating strategy effectiveness.
//@version=6
strategy("Stat Arb(xag & xau)")
// ══════════════════════════════════════════════════════════════
// BENCHMARK DATA
// ══════════════════════════════════════════════════════════════
float benchClose = request.security("XAG_USDT.swap", timeframe.period, close)
// ══════════════════════════════════════════════════════════════
// HELPER FUNCTIONS
// ══════════════════════════════════════════════════════════════
f_cov(float src1, float src2, int len) =>- 1

