Bullion Dollar StatArb Gauge Loop MT5
- Indicatori
-
Anthony Cooke
Quantitative Systems Architect and C++, Python, MQL5, MQL4, and Pine Script developer specializing in non-repainting mathematical indicators, Expert Advisors, and statistical strategy audits. I combine industrial quality-control engineering and Applied Mathematics with multi-physics market modeling - Versione: 1.10
- Attivazioni: 5
Overview & Scientific Origin
The Bullion Dollar StatArb Gauge Loop is an institutional quantitative indicator engineered from Quantitative Pairs Trading (Statistical Arbitrage) and Lattice Gauge Theory (Theoretical Physics). Institutional prop desks use rolling Ordinary Least Squares (OLS) dynamic hedge ratios to measure when two correlated markets diverge abnormally far from fair value, while physicists use Wilson Gauge Loop Phase Holonomy to measure rotational flux and lead-lag curvature around closed state-space loops. Combining both frameworks into a single strictly causal, non-repainting subwindow oscillator (-4.5 to +4.5), this tool exposes relative mispricing and cross-market capital rotation for Gold (XAUUSD), Silver (XAGUSD), Major Forex pairs, and US Indices.
Mathematical Mechanism & Visual Guide
Rather than relying on static correlation numbers that fail when volatility changes, the engine recalculates the exact log-price relationship between your chart symbol and your chosen benchmark on every closed bar:
- Dual-Color OLS Spread Z-Score Histogram (StatArb_Pos & StatArb_Neg): Across your rolling lookback window (InpPeriod = 55), the algorithm computes the live OLS hedge ratio (β) and normalizes the residual mispricing spread into an intuitive two-color histogram—MediumSeaGreen bars above 0.0 highlight positive spread stretching (overbought relative to the benchmark), while OrangeRed bars below 0.0 highlight negative spread stretching (oversold relative to the benchmark).
- Smoothed Wilson Gauge Loop Flux (Gauge_Loop_Flux): Across a faster phase window (InpLoopWindow = 13), the indicator calculates the discrete Wilson loop area in standardized two-asset state space. To ensure ultra-clean visual readability without flatlining against chart borders, the loop is rolling mean-centered, smoothed via a 3-bar EMA, and smoothly compressed with a hyperbolic tangent (tanh) into a continuous Gold curve that reveals lead-lag phase rotation.
- Automatic Single-Symbol & Strategy Tester Mode (SELF): Attach it to XAUUSD against EURUSD (default) or XAGUSD, or set InpInvertRef = true for inversely correlated benchmarks like USDCHF, USDJPY, or DXY/USDX. If attached to the same symbol as InpRefSymbol or run in a single-symbol Strategy Tester, it automatically engages a mean-centered causal phase fallback (SELF mode) so signals stay balanced and backtesting never breaks.
How to Trade With This Indicator
- Overbought Reversion Setup (Green Histogram > +2.0): When MediumSeaGreen bars stretch above the +2.0 band, the chart asset is statistically overextended relative to its benchmark; watch for the bars to peak and the Gold Gauge_Loop_Flux line to roll over downward to time mean-reversion shorts.
- Oversold Reversion Setup (Red Histogram < -2.0): When OrangeRed bars plunge below the -2.0 band, the asset is statistically undervalued; watch for the Gold phase curve to curl upward across 0.0 to confirm the bullish snapback.
- Momentum Lead-Lag Confirmation: When the Gold line surges strongly ahead of the histogram crossing 0.0, capital is rotating into the new direction—useful as a macro confluence filter for trend entries.
Technical Specifications & Input Parameters
- Calculation Engine: 100% causal bar-by-bar execution with zero repainting, zero backpainting, and zero external DLL calls.
- InpRefSymbol (Default: "EURUSD"): Reference benchmark symbol (match your broker's exact suffix, e.g., EURUSD.m or XAGUSD; leave blank for SELF phase mode).
- InpInvertRef (Default: false): Inverts reference log-price polarity—set true for inversely correlated benchmarks like USDCHF, USDJPY, or DXY/USDX.
- InpPeriod (Default: 55): Rolling lookback window for OLS dynamic hedging, spread Z-score scaling, and Gauge Loop mean centering.
- InpLoopWindow (Default: 13): Phase holonomy lookback window for lead-lag rotation speed.
- InpBandLevel (Default: 2.0): Symmetric upper and lower Z-score bands flagging statistical reversion extremes.
- Prop-Firm & EA Ready: Exposes StatArb_Pos (Buffer 0), StatArb_Neg (Buffer 1), Gauge_Loop_Flux (Buffer 2), plus a dedicated hidden continuous StatArb_Net line (Buffer 3) so Expert Advisors can read signed spread Z-scores in a single iCustom() call.
####
Timeframe, Pair & Volatility Calibration (Customize to Your Chart)
The default settings (55 / 13 / 2.0 against EURUSD) provide a balanced M15–H1 starting point, and every parameter can be tailored to your exact asset pair and timeframe:
- Cross-Market Pair Ideas: Run on XAUUSD with InpRefSymbol = "XAGUSD" (Gold/Silver arbitrage) or "EURUSD" (Bullion/Dollar), run on US100 against "US500" (Tech vs. Broad Index), or compare correlated FX majors like AUDUSD vs. "EURUSD".
- Faster Intraday Scalping (M5–M15): Reduce InpPeriod to 21–34, shorten InpLoopWindow to 8, and tighten InpBandLevel to 1.75 for quicker spread snapbacks.
- Macro Swing Arbitrage (H1–D1): Expand InpPeriod to 89–144, lengthen InpLoopWindow to 21, and widen InpBandLevel to 2.5 to isolate only high-conviction multi-day dislocations.
-------Also Available for MetaTrader 4 (MT4): Running MT4 instead of MT5? The identically engineered MetaTrader 4 version of Bullion Dollar StatArb Gauge Loop is already published on my MQL5 Seller Profile with the exact same icon, parameters, and mathematical engine. Click my seller name to grab the MT4 edition.
