Delphi Regression EA
- Experts
-
Alexandre Vincent Traber
Algorithmic trading developer building Expert Advisors for MetaTrader 5. - Version: 1.0
Delphi Regression EA — Multi-Strategy Adaptive Linear Regression System
Overview
Delphi Regression EA builds a rolling linear regression channel on closed bars and trades price deviation from that channel using three independently selectable strategies: mean reversion, trend continuation, and slope reversal. Position sizing is percent-risk based, stops are ATR-derived, and every optimization pass is ranked by a custom equity-curve-quality score instead of raw net profit, so the optimizer favors robust, repeatable behavior over lucky curve-fitted runs.
How It Works
- On every new bar, a linear regression is computed over the last N closed bars, producing a center line, slope, R-squared, and residual standard deviation.
- Multiple entry tiers are placed at stepped multiples of the residual standard deviation on each side of the center line.
- Mean reversion fades price back toward center when a tier is touched. Trend continuation trades in the slope's direction when R-squared confirms a genuine trend. Slope reversal opens a position when the regression slope flips sign.
- Each tier re-arms independently once price retraces part of the way back toward center, allowing several entries per swing instead of a single shot per move.
- Exits are either a bar-close return to the center line or a broker-side TP/SL, selectable independently from entries.
- Entry and exit execution can each be switched between an Open-Price-safe mode (decision made purely on closed bar data) and a broker-fill mode requiring 1-Minute OHLC or better.
Inputs
General
- Magic_Number — unique identifier for this EA's trades
- Trade_Comment — comment tag attached to every order
Regression
- LR_Period — number of closed bars used to compute the regression line
- LR_TierStep — distance between entry tiers, expressed in residual standard deviations
- LR_TierCount — number of scaling tiers placed on each side of the center line
- LR_TierRearmFrac — fraction of one tier step price must retrace before that tier can fire again
- Filter_UseR2Gate — enables or disables filtering entries by an R-squared window
- LR_MinR2ForEntry — minimum R-squared required for entries when the gate is enabled
- LR_MaxR2ForEntry — maximum R-squared allowed for entries when the gate is enabled
Strategy Selection
- Strat_MeanReversion — enables the tiered fade-to-center strategy
- Strat_TrendContinuation — enables trading with the slope on tier breakouts
- Trend_MinR2 — minimum R-squared required for a trend continuation signal to fire
- Strat_SlopeReversal — enables entries on regression slope sign flips
- SlopeRev_MinAbsSlope — minimum absolute slope magnitude required for a reversal signal to fire
Signal Mode
- Entry_Mode — Open-Price-safe market entry on closed bar data, or intrabar pending orders requiring 1-Minute OHLC or better
- Exit_Mode — Open-Price-safe bar-close exit, or broker-side TP/SL requiring 1-Minute OHLC or better
- Pending_ExpiryBars — number of bars before an unfilled pending order is auto-deleted
Risk
- Risk_PercentPerTrade — percentage of account equity risked per trade
- Risk_ATR_SL_Mult — stop-loss distance as a multiple of ATR
- Risk_ATR_Period — period used for the ATR calculation
- Risk_MaxConcurrentTrades — maximum number of simultaneous open positions for this EA
Filters
- Filter_MaxSpreadPoints — maximum spread, in points, allowed before entries are skipped
Optimizer Score
- Score_MinProfitFactor — disqualifies optimization passes below this profit factor
- Score_MaxDrawdownPct — disqualifies passes above this drawdown percentage
- Score_MinTrades — disqualifies passes with fewer than this many trades
- Score_R2Weight — weight given to equity curve smoothness
- Score_SlopeWeight — weight given to profit speed
- Score_SplitPenalty — penalty for divergence between first-half and second-half equity curve R-squared
- Score_SkewPenalty — penalty for profit concentration in a single trade
- Score_UlcerPenalty — penalty based on the Ulcer Index (drawdown depth and duration)
- Score_MARWeight — weight given to the MAR ratio (net profit percent over max drawdown percent)
- Score_TradeBonusWeight — weight given to a diminishing-returns bonus for trade count
Optimizer Scoring System
This EA ships with a custom OnTester scoring function designed to reward smooth, stable equity curves rather than high-profit runs prone to curve-fitting. It disqualifies any optimization pass with negative profit, insufficient profit factor, excessive drawdown, or too few trades, then ranks the remaining passes on equity curve smoothness, profit speed, temporal stability, capital efficiency, and trade count reliability, while penalizing single-trade profit concentration and drawdown pain. Set the MT5 Optimizer Criterion to Custom max to activate it.
Recommended Setup
Screenshots shown are from XAUUSD, M30, tested in Every Tick mode for maximum execution fidelity. The regression-based logic is not tied to this symbol or timeframe: other Forex pairs, metals, or indices, and other timeframes, can be optimized independently by re-running the optimizer with Custom max criterion on your chosen instrument.
Screenshots
Live backtest example and recommended input configuration on XAUUSD M30, Every Tick mode.
Disclaimer
Past backtest performance does not guarantee future results. Always forward-test on a demo account before live deployment. Trading involves risk of loss.
