BreakoutStrategy
This EA implements a channel breakout strategy that places BuyStop and SellStop pending orders when price breaks above the highest high or below the lowest low of a configurable lookback period. It uses a trailing stop mechanism based on the opposite channel boundary or middle line, and sizes positions based on a fixed risk percentage of equity per trade.
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: No blow-up pattern found
None of the usual blow-up patterns were found in the code, and the account was not stopped out in our backtests. That is not a guarantee: any EA can lose money.
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
The strategy concept is based on a Donchian-style channel breakout, using the highest high and lowest low over N periods to form a price channel, going long on upside breakouts and short on downside breakouts. Entry conditions: when no position exists in the same direction, a BuyStop order is placed above the highest high plus one tick, and a SellStop order is placed below the lowest low minus one tick. Exit conditions use a trailing stop mechanism: if middle-line exit is enabled, the long trailing stop follows the greater of the middle line and the lowest low, while the short trailing stop follows the lesser of the middle line and the highest high; if disabled, longs trail the lowest low and shorts trail the highest high. When price reverses past the trailing line the position is closed directly, otherwise the trailing line is set as the new stop loss via PositionModify. Position sizing is based on a fixed risk-per-trade model, using OrderCalcProfit to compute the loss for 1 lot at the stop-loss distance, then deriving lot size from the risk amount and rounding down to the symbol's minimum volume step. Money management also includes a mechanism to reduce lot size when free margin is insufficient, and handles cases where lot size exceeds the maximum volume by splitting into multiple orders. On the order management side, all unfilled pending orders are deleted and re-placed at each new bar open, using ORDER_TIME_DAY expiry to avoid stale overnight orders.
Strengths
- Fixed risk-per-trade position sizing keeps risk controlled and adapts to account size
- Pending order entry avoids slippage, and stop-loss/trailing-stop logic provides a complete risk management framework
- Channel breakout logic is clear and concise with highly configurable parameters, easy to understand and backtest
- Handles max volume limits via order splitting and reduces lot size when free margin is insufficient
- Logic executes only on new bar open, avoiding high-frequency and over-trading
Weaknesses
- ATR indicator handle is created on every call to ATR() but never released, causing a serious resource leak
- Pending orders use only ORDER_TIME_DAY expiry, which may cause unexpected behavior when weekends or holidays are skipped
- No symbol filter, trading session filter, or news event filter, potentially generating unfavorable entries during low-liquidity periods
- positions-- after closing a position in PositionManaging may cause index offset issues since the loop iterates from high to low
- No error checking or handling on return values of trade operations (BuyStop, SellStop, PositionModify, etc.)
Possible improvements
- Move ATR indicator handle creation to OnInit() and release in OnDeinit() to avoid resource leak from repeated creation on every call
- Add error checking and retry logic for all trade operations, and log failure reasons for debugging
- Add trading session filter and spread filter to avoid entries during low-liquidity or high-spread periods
Risk assessment
Overall risk: Medium
- ATR handle resource leak may degrade terminal performance or cause crashes during extended running
- No error checking on trade operations means failures go unnoticed, potentially causing strategy state to diverge from actual positions
- Lack of session and spread filters may lead to entries under adverse conditions with excessive slippage
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
BOT_NAME | BreakoutStrategy | EA name identifier |
EXPERT_MAGIC | 1 | EA magic number for identifying its orders |
ENTRY_PERIOD | 20 | Entry channel lookback period |
ENTRY_SHIFT | 1 | Entry channel shift (1=from previous bar) |
EXIT_PERIOD | 20 | Exit channel lookback period |
EXIT_SHIFT | 1 | Exit channel shift |
EXIT_MIDDLE_LINE | true | Use channel middle line as exit reference |
TRADING_TIMEFRAME | PERIOD_H1 | Trading timeframe |
RISK_PER_TRADE | 0.01 | Risk per trade as equity percentage (1%) |
Similar Breakout EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.