Trade Setup MT5 Pro
- Indicators
- Version: 2.0
QuantSetup — Institutional-Grade Bidirectional Mean-Reversion Engine (v3.00)
QuantSetup is an advanced, quantitative trading setup and management engine built for MetaTrader 5. Moving far beyond traditional, lagging indicators, QuantSetup integrates rigorous statistical and econometric models—including Hurst Exponents, Ornstein-Uhlenbeck (OU) stochastic processes, and GARCH(1,1) volatility scaling—to identify, filter, and manage high-probability mean-reversion (and optional trend-continuation) setups.
Designed with a strict no-repainting architecture operating exclusively on closed bars, it provides discretionary traders with a clear visual roadmap and algorithmic developers with a robust iCustom suite for Expert Advisor (EA) automation.
🚀 Key Features & Quantitative Edge
1. Advanced Statistical & Regime Filtering
- Ornstein-Uhlenbeck (OU) Process Fit: Continuously calculates mean-reversion parameters ($b < 0$), ensuring entries occur only when price dynamics show valid mean-reverting half-lives within your custom range (e.g., 2 to 60 bars).
- Hurst Exponent Regime Filter: Uses an aggregated-variance estimator across multiple lags ($\tau = 1, 2, 4, 8, 16$) to gauge market memory. Dynamically separates mean-reverting regimes ($H < 0.5$) from trending regimes ($H > 0.5$).
- Z-Score Entry Thresholds: Identifies statistical price stretching ($z \ge +thr$ for shorts, $z \le -thr$ for longs) using a rolling window mean and standard deviation.
- Drift Context Filter: Employs a scale-free t-statistic to measure and optionally filter out trades fighting strong multi-bar directional drifts.
2. Dynamic Volatility-Scaled Risk Management
- GARCH(1,1) Conditional Variance: Dynamically scales protective stops using GARCH-adjusted Average True Range (ATR), accounting for volatility clustering, sudden shocks, and persistence parameters ($\alpha, \beta$).
- Intelligent Take-Profit (TP) Capping: Automatically targets a customizable Risk-to-Reward (R:R) ratio, capped intelligently by:
- Nearest swing support/resistance structures and confirmed pivot points.
- The OU expected-reversion horizon level.
- Plan Quality Gate: Computes a probabilistic model of hitting the TP ($P(TP)$) before the stop loss, filtering out trades with low Expected Value (EV) or unfavorable spread-to-risk ratios.
3. Advanced Trade & Lifecycle Management
- Breakeven Automation: Automatically shifts the stop loss to breakeven once price reaches a configured multiple of initial risk ($1R$).
- Chandelier Volatility Trailing Stop: Ratchets the protective stop dynamically using ATR multiples based on extreme prices reached during the trade lifecycle.
- Time Stop: Automatically closes or expires stale plans based on a configured max holding period or a multiple of the OU half-life.
- Re-Arm & Cooldown Rules: Enforces cooldown bars after exits and requires price to re-converge closer to the mean before allowing subsequent signals.
4. Robust Market & Environmental Filters
- Session & Time Windows: Restrict trading to specific hours of the day.
- Blackout Windows: Define up to two daily blackout periods to avoid high-impact macroeconomic news releases.
- Friday Cutoff: Prevents opening new positions heading into the weekend close.
- Gap Protection: Holds off on new entries for $N$ bars following significant market gaps.
- Spread & Volatility Bands: Automatically skips trades when the live spread exceeds safety limits or when market volatility falls into dead zones or shock spikes.
5. Built-In Position Sizing & Live Analytics Panel
- Risk-Based Lot Sizing: Automatically calculates lot sizes based on a designated percentage of your account balance or equity, factoring in contract specifications and round-turn commissions.
- Real-Time Statistics HUD: Displays live metrics right on your chart, including Hurst, Z-score, OU half-life, GARCH vol ratio, win rates, profit factor, Kelly criterion recommendations, and maximum drawdown in $R$-multiples.
- CSV Trade Journal: Optionally writes complete trade execution and performance analytics directly to MQL5/Files for offline quantitative auditing.
📊 Visual Elements & Chart Interface
- Smoothers: Choose between a Hull Moving Average (HMA) or a 1-D Kalman Filter for underlying trend/smoothing visualization.
- Live Preview Mode: While flat, the indicator projects a live grey preview box outlining potential setups when $\vert{}z\vert{}$ approaches your threshold, helping you anticipate market moves before signals fire.
- Historical Plan Fading: Keeps closed plans visible on the chart in a dimmed format with outcomes clearly labeled ($TP$, $SL$, or time stops), ensuring full backtest transparency without clutter.
🔌 EA & Robot Integration ( iCustom Buffers)
QuantSetup is fully equipped for automated trading integration. Using CopyBuffer (reading shift 1 for the last closed bar), EAs can seamlessly pull signals, entry prices, stops, and state events:
| Buffer Index | Description | Return Value / Data |
| 0 | Smoother Line | Hull MA or Kalman Filter value |
| 1 | Sell Arrow | Arrow plotted above bar on short entry |
| 2 | Short TP Hit | Marker when short take-profit is reached |
| 3 | Buy Arrow | Arrow plotted below bar on long entry |
| 4 | Long TP Hit | Marker when long take-profit is reached |
| 5 | Signal | $+1$ for Buy, $-1$ for Sell on entry bar, else $0$ |
| 6 | Entry Price | Active plan entry price, else $0$ |
| 7 | Stop Loss | Current protective stop (adjusts with BE/Trail) |
| 8 | Take Profit | Target take-profit price |
| 9 | State | Side $\times$ Phase ($\pm 1$ open, $\pm 2$ breakeven, $\pm 3$ trail) |
| 10 | Event Code | Side $\times$ Code (1: Entry, 2: BE Arm, 3: Trail Arm, 4: TP, 5: SL, 6: BE Stop, 7: Trail Stop, 8: Time Stop) |
⚙️ Input Parameters Summary
- Direction: Choose between Long & Short, Long Only, or Short Only.
- Smoother Settings: Select HMA or Kalman Filter with adjustable lengths and parameters.
- Regime Filter: Configure Hurst window length ($60–400$) and threshold levels.
- Entry (OU & Z-Score): Set Z-score window, sigma threshold, half-life boundaries, and re-arm rules.
- Stop Loss & Take Profit: Tailor GARCH parameters, ATR length, multipliers, R:R targets, and pivot strength.
- Trade Management: Adjust breakeven triggers, Chandelier trail multipliers, and time-stop rules.
- Market Filters: Configure session hours, blackout schedules, Friday cutoffs, gap filters, and spread caps.
- Position Sizing & Alerts: Set risk percentages, commission rates, push/email/popup alerts, and CSV logging.
