KeltnerBB Fade
- Experts
- Version: 1.33
Overview
KeltnerBB_Fade is a mean-reversion Expert Advisor for MetaTrader 5. It fades extreme volatility expansions by detecting when Bollinger Bands approach or cross Keltner Channels, then trades back toward the mean. ATR-based stop loss and dynamic position sizing on every trade.
How it works
- Bollinger Bands and Keltner Channels are computed on the current timeframe.
- Entry fires when the BB upper/lower band approaches or crosses the KC upper/lower band (configurable: strict cross or proximity threshold).
- Position size is calculated from account equity and Risk_Percent, with an ATR-based stop loss.
- Exit is chosen from five configurable modes (mean revert to middle band, band re-entry, squeeze inverse, opposite signal, RSI momentum fade).
- Optional profit-protection layer: R-multiple partial-close ladder, breakeven lock, time-in-profit close, and/or a percent-of-balance trailing ladder.
- All exits and profit-protection triggers are evaluated on closed-bar High/Low/Close only, for identical behavior across OHLC and Every Tick testing.
Inputs
General
- Magic Number: unique identifier for this EA's trades
- Risk Percent: risk per trade, % of account equity
- ATR Period Risk: ATR period used for stop loss sizing
- ATR SL Multiplier: stop loss distance as a multiple of ATR
- Margin Safety Factor: max margin usage relative to free margin, buffer against adverse gap moves
Bollinger
- BB Period
- BB Deviation
- BB Price: applied price for Bollinger calculation
Keltner
- KC EMA Period
- KC ATR Period
- KC ATR Multiplier
Signal Mode
- Signal Mode: strict cross (rare, original behavior) or proximity threshold (more frequent)
- Signal Proximity Pct: % of Keltner channel width used as the approach buffer in proximity mode
Exit
- Exit Mode: mean revert, band re-entry, squeeze inverse, opposite signal, or momentum fade
- RSI Period
- RSI Upper
- RSI Lower
Profit Lock
- Lock Breakeven Enable: move stop loss to breakeven once triggered
- Lock Breakeven Trigger R: trigger level, in R-multiples of initial stop distance
- Lock Breakeven Buffer Points: buffer beyond entry price, in points
- Lock Ladder Enable: partial close on R-multiple tiers
- Lock Ladder R1 / R1 Pct: tier 1 trigger and close percentage
- Lock Ladder R2 / R2 Pct: tier 2 trigger and close percentage
- Lock Ladder R3 / R3 Pct: tier 3 trigger and close percentage
- Lock Time In Profit Enable: partial close after N consecutive bars in profit
- Lock Time In Profit Bars: bars required
- Lock Time In Profit Pct: close percentage
- Lock Pct Ladder Enable: full-close trailing ladder based on percent of account balance
- Lock Pct Ladder Activation Pct: floating profit percentage that arms the ladder
- Lock Pct Ladder Trail Step Pct: ladder step size, in percent
Optimizer Score
- Score Min Profit Factor: disqualification threshold
- Score Max Drawdown Pct: disqualification threshold
- Score Min Trades: disqualification threshold
- Score R2 Weight: weight of equity curve smoothness
- Score Slope Weight: weight of profit speed
- Score Split Penalty: penalty for temporal instability between first/second half of the test
- Score Skew Penalty: penalty for profit concentration in a single trade
- Score Ulcer Penalty: penalty for drawdown depth and duration
- Score MAR Weight: weight of net profit relative to max drawdown
- Score Trade Bonus Weight: weight of trade count reliability bonus
Optimizer scoring system
This EA includes a custom OnTester scoring function designed to fight curve-fitting. It ranks optimization runs by equity curve smoothness (R²), profit speed (slope), temporal stability (divergence between first and second half of the test), profit concentration (single-trade skew), drawdown depth and duration (Ulcer Index), capital efficiency (MAR ratio), and trade count reliability. Runs with negative profit, profit factor, drawdown, or trade count below the disqualification thresholds are automatically scored zero. Set Optimizer Criterion to Custom max when running the built-in optimizer.
Recommended setup
Test in Every Tick mode on real ticks, on the timeframe and symbol matching your target market. Broker with tight spreads and low stop/freeze levels recommended for tighter breakeven and partial-close execution.
Screenshots
Recommended .set files are provided in the comments section below.
Disclaimer
Past performance shown in backtests does not guarantee future results. Always test on a demo account before live use. Trading involves risk of loss.
