RangeBreakout
This EA implements a periodic range breakout strategy that identifies a price range center at a specified day and hour each week, then places pending-style breakout trades when price breaks above or below the calculated range. It incorporates ATR-based range calculation with a martingale position sizing recovery system after losses, and uses take-profit/stop-loss levels derived from the range size.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
| Symbol | P&L | Annual | Max DD | Trades | Win rate | Sharpe | Recovery | Losing streak | Per trade | Status |
|---|---|---|---|---|---|---|---|---|---|---|
| EURUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| GBPUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| USDJPY | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| XAUUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
Why this EA never traded: no entry rule survived the conversion.
Converted from MQL5 to Python and run with the same rules for every EA. Positions use MT5 lot sizes (100,000 units per FX lot, 100 oz per gold lot) with 1:100 leverage, one order at a time, and a stop-out below 10% of the starting balance. Sharpe is computed from the equity curve. Results marked as unreliable are shown for completeness only.
Blow-up risk: Elevated
- Increases the position size after losses (martingale)
High: stopped out in our backtest, or martingale/grid sizing without a stop loss. Elevated: martingale or grid sizing with a stop loss, or several positions at once without a stop loss. What the label means and what we found →
Strategy analysis
Strategy concept: This EA is a periodic range breakout system that establishes a price center using the previous H1 candle close at a user-specified day and hour each week, then calculates breakout boundaries using either ATR or a price percentage. Entry conditions: A buy order is opened when the Ask price breaks above the upper range boundary (pHighStop), and a sell order is opened when the Bid price breaks below the lower range boundary (pLowStop); only one trade direction is allowed at a time. Exit conditions: Trades are closed automatically via take-profit and stop-loss levels derived by scaling the Range value by configurable percentages. Position sizing: A martingale system doubles the lot multiplier (kLot) after each loss and resets it to 1 after a win, while also computing a cumulative loss compensation value (comLoss) that inflates the take-profit target to recover prior losses. Money management: The EA checks if free margin exceeds 1000*Lot before opening a trade, but this check fails to account for the kLot multiplier, significantly underestimating the actual margin requirement when martingale scaling is active. The strategy logic is coherent but the martingale mechanism introduces extreme risk, potentially causing rapid account blowup on small accounts during losing streaks.
Strengths
- Clean and intuitive strategy concept with straightforward breakout logic that is easy to understand and tune
- Uses ATR indicator for dynamic range calculation, allowing the strategy to adapt to changing market volatility
- Thorough input validation with boundary checks and sensible defaults for all percentage parameters and weekend day selection
- Proper lot size normalization in SetVolume function that correctly handles min/max volume and step alignment
Weaknesses
- Martingale system carries extreme risk; lot size doubles after each loss, potentially causing rapid account blowout during losing streaks
- Critical margin check bug: uses 1000*Lot instead of 1000*Lot*kLot, severely underestimating actual margin requirement when martingale scaling is active
- No trade state persistence mechanism; reliance on PositionSelectByTicket for detecting closure means trade state can be lost on disconnect or EA restart
- The comLoss compensation mechanism is unsafe: setting TP to comLoss while widening SL creates severely unfavorable risk-reward ratios after losses
- No spread filter, meaning breakouts during low-liquidity sessions could be falsely triggered by wide spreads
Possible improvements
- Remove or cap the martingale system; replace with fixed lot or volatility-based position sizing (e.g., ATR-proportional scaling) to avoid exponential risk growth
- Fix the margin check bug by changing 1000*Lot to 1000*Lot*kLot to correctly reflect the actual margin requirement under martingale scaling
- Add trade state persistence (e.g., global variables or file storage) to ensure correct trade state recovery after EA restart or connection loss
- Add spread filter and minimum volatility threshold to prevent false breakout signals during low-liquidity sessions
- Add maximum consecutive loss count limit and maximum lot cap to prevent the martingale system from running out of control
Risk assessment
Overall risk: Dangerous
- Martingale lot doubling causes exponential position growth during consecutive losses, potentially draining the account rapidly
- Margin check uses base lot instead of actual multiplied lot, potentially allowing oversized trades beyond account capacity
- The comLoss compensation widens stop-loss after losses while adjusting take-profit, causing per-trade risk to escalate with cumulative losses
- No disconnect recovery mechanism; lost trade state could lead to duplicate positions or missed closures
- Double semicolon syntax error (return;;) while compilable suggests insufficient code review
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
inDay | MONDAY | Day of week for weekly trigger setting |
inHour | H00 | Start hour for weekly trigger setting |
inPerPrice | 1 | Price percentage (0.3%-3%), fallback range calculation when ATR fails |
inPerATR | 100 | ATR percentage (10%-200%), scales ATR value as breakout range |
inPerProfit | 100 | Take profit percentage (10%-200%), TP distance based on Range |
inPerLoss | 100 | Stop loss percentage (10%-200%), SL distance based on Range |
inLot | 0.1 | Base trading lot size |
Similar Breakout EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.