Alpha Decay Half Life Auditor MT4
- 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 AND SCIENTIFIC ORIGIN
The Alpha Decay Half Life Auditor is a dual-engine quantitative indicator engineered from Stochastic Physics (Ornstein-Uhlenbeck Mean-Reversion Dynamics) and Quantitative Strategy Auditing. In institutional portfolio management, directional trading signals do not stay valid indefinitely: market regimes shift between persistent trending behavior and rapid mean-reverting chop, while individual trading strategies experience measurable alpha decay as holding time lengthens.
Rather than occupying a chart Expert Advisor slot, this tool runs two independent quantitative engines simultaneously inside a single subwindow so it stacks cleanly alongside any manual workflow or automated Expert Advisor across Forex pairs, Gold (XAUUSD), Silver (XAGUSD), and Indices:
1. Live Market Persistence Engine (Histogram, White Curve, and Top 2 HUD Lines): Runs strictly on live chart price data, independent of your account orders, measuring real-time market half-life and directional edge retention.
2. Account Trade-History Decay Audit Engine (Bottom 2 HUD Lines and Optional CSV Export): Scans your closed account trade history by holding duration to identify the exact hour bracket where your realized trade expectancy peaks or begins degrading.
ENGINE 1 - LIVE MARKET PERSISTENCE AND HALF-LIFE
On every closed bar across your lookback window (InpPeriod = 60), the indicator fits a strictly causal rolling AR(1) Ordinary Least Squares Ornstein-Uhlenbeck regression on log-prices: d ln(P_t) = a + b * ln(P_{t-1}) + eps_t. From the regression slope, it derives three physical persistence metrics in real time:
- Continuous-Time Decay Rate (LAM / theta): Quantifies how quickly price deviations are pulled back toward equilibrium.
- Physical Market Half-Life (Hours and Bars): Computes ln(2) / theta to show the exact number of bars and physical clock hours required for directional persistence to decay by 50 percent.
- Alpha Retention Percentage (0% to 100%): Evaluates exp(-theta * Horizon) across your selected evaluation window. By default (InpFixedHorizonHrs = 0.0), the horizon auto-scales cleanly to InpEvalHorizonBars (8 bars) across all timeframes from M5 to D1. Entering any positive hour value into InpFixedHorizonHrs (for example, 31.0 hours) locks the decay audit to that exact fixed clock duration.
ENGINE 2 - ACCOUNT TRADE-HISTORY DECAY AUDIT
Independent of the live price histogram, the history engine inspects your closed trade records (net profit and loss inclusive of swap and commission) and sorts every completed trade into four holding-duration buckets:
- Under 4 hours (<4h)
- 4 to 16 hours (4-16h)
- 16 to 36 hours (16-36h)
- Over 36 hours (>36h)
It computes expectancy per trade (EXP/TRADE) for every bucket and highlights the OPTIMAL HOLD bracket with the leading per-trade expectancy directly on the HUD. On fresh accounts or Strategy Tester runs with zero closed trades, the bottom HUD section transitions cleanly to LIVE MARKET SCAN MODE (0 CLOSED) while Engine 1 continues operating at full capacity. Enabling InpExportCSV = true exports a structured report file (AlphaDecay_Audit_<Symbol>.csv) containing trade counts, win rate percentage, total net P&L, and expectancy for each duration bucket.
VISUAL GUIDE AND SOLID DARK HUD PANEL
Subwindow Scale (0.0 to 105.0, with dashed horizontal reference lines at 75.0, 50.0 [exact Half-Life], and 25.0):
- MediumSeaGreen Histogram (Edge_Healthy, 50% and above): Persistent trending regime where directional momentum outlasts the evaluation horizon.
- Gold Histogram (Edge_Decaying, 25% to 50%): Mean reversion is accelerating and trend persistence is fading.
- Crimson Histogram (Edge_Exhausted, below 25%): Fast mean-reverting chop where trend-following holds degrade quickly.
- WhiteSmoke Smooth Line (Alpha_Retention_Curve): Smoothed structural retention curve tracking regime transitions without bar-to-bar noise.
Solid Dark Telemetry HUD (Upper-Right Subwindow, dark slate panel with DodgerBlue border so tall histogram bars never obscure the readout):
- Line 1 (ALPHA DECAY AUDITOR): Live market persistence state (EDGE HEALTHY, EDGE DECAYING, or EDGE EXHAUSTED) and smoothed retention percentage.
- Line 2 (MARKET HALF-LIFE): Live physical half-life in hours and bars alongside the continuous decay rate (LAM).
- Line 3 (HISTORY AUDIT): Total closed trades audited and the OPTIMAL HOLD bucket (<4H, 4-16H, 16-36H, or >36H), or LIVE MARKET SCAN MODE when zero closed trades exist.
- Line 4 (EXP/TRADE): Side-by-side average net expectancy per trade across all four holding-time brackets.
PRACTICAL USAGE
Regime Selection for Entries and Exits:
Favor trend-following and breakout setups when MediumSeaGreen bars hold cleanly above the 50.0 half-life line and the HUD reads EDGE HEALTHY. When bars transition into Gold (25% to 50%) or Crimson (below 25%), tighten trailing stops, scale out of extended trend holds, or shift focus toward shorter mean-reversion windows.
Auditing Your Holding Time:
Review Lines 3 and 4 of the HUD after accumulating live or demo trade history. If expectancy is positive in <4h or 4-16h but turns negative in 16-36h or >36h, your strategy edge is decaying with time—providing objective data to set a trade time-stop or faster take-profit rule.
TECHNICAL SPECIFICATIONS AND INPUT PARAMETERS
Calculation Engine:
100 percent causal bar-by-bar indexing with zero repainting, zero backpainting, and zero external DLL calls. Subwindow short name: AlphaDecay_HL(60).
Market Half-Life Engine Inputs:
- InpPeriod (Default: 60): Rolling bar count used for the causal AR(1) OLS Ornstein-Uhlenbeck regression.
- InpEvalHorizonBars (Default: 8): Auto-scaled bar horizon used when InpFixedHorizonHrs is set to 0.0.
- InpFixedHorizonHrs (Default: 0.0): Optional fixed evaluation horizon in clock hours (0.0 enables automatic timeframe scaling; set a positive number such as 24.0 or 31.0 to audit against a fixed holding target).
Account History Audit and Display Inputs:
- InpAuditAllSymbols (Default: true): True audits closed history across all account symbols; false restricts the audit strictly to the current chart symbol.
- InpAuditMagic (Default: 0): Magic Number filter (0 audits all manual and automated trades; enter a specific Magic Number to isolate one Expert Advisor).
- InpMaxAuditDeals [MT5] / InpMaxAuditTrades [MT4] (Default: 1000): Maximum number of recent closed records scanned per audit update.
- InpExportCSV (Default: false): Set true to save the 4-bucket expectancy summary table to AlphaDecay_Audit_<Symbol>.csv in the terminal Files folder.
- InpShowHUD (Default: true): Toggles the solid dark telemetry panel (automatically bypassed during Strategy Tester optimization).
Expert Advisor Integration (iCustom Buffer Map):
- Buffer 0: Edge_Healthy (MediumSeaGreen bars >= 50%)
- Buffer 1: Edge_Decaying (Gold bars 25% to 50%)
- Buffer 2: Edge_Exhausted (Crimson bars < 25%)
- Buffer 3: Alpha_Retention_Curve (WhiteSmoke smoothed retention curve)
- Buffer 4: OU_HalfLife_Hours (Hidden continuous physical half-life in hours)
- Buffer 5: OU_Decay_Lambda (Hidden continuous OU decay rate theta)
TIMEFRAME AND VOLATILITY CALIBRATION (CUSTOMIZE TO YOUR CHART)
The default settings (60-bar regression, 8-bar auto-scaled horizon, all-symbol history audit) adapt cleanly from M5 to D1 across Forex, Gold, and Indices, and can be tuned directly to your trading horizon:
- Intraday Scalping (M5 to M15): Lower InpPeriod to 35 to 45 for faster regime detection and set InpEvalHorizonBars to 6 to 10 bars (or lock InpFixedHorizonHrs to 2.0 to 4.0 hours to match short intraday holds).
- Swing and Multi-Session Holds (H1 to H4): Keep InpPeriod at 60 to 80 and set InpFixedHorizonHrs to match your typical target holding window (for example, 16.0, 24.0, or 31.0 hours) so the 50% line reflects your actual holding duration.
- Single-EA Performance Audit: Set InpAuditMagic to a specific Expert Advisor's Magic Number and InpAuditAllSymbols to false if you want to measure holding-time decay for one strategy on one symbol, then toggle InpExportCSV = true to export the bucket table for spreadsheet review.
-----ALSO AVAILABLE FOR METATRADER 5 (MT5) Trading on MetaTrader 5 instead of MetaTrader 4? The identically engineered MetaTrader 5 edition of Alpha Decay Half Life Auditor is published on my MQL5 Seller Profile with the exact same thumbnail, dual-engine half-life oscillator, account history decay audit HUD, CSV export, and parameter set. Visit my seller profile to access the MT5 version.
