NarrowestRangeSignal EA
This EA places bracket stop orders (buy stop above and sell stop below) when the NarrowestRangeSignal indicator identifies a narrow price range. When one side triggers, the opposite pending order is deleted, implementing an OCO (One-Cancels-Other) breakout strategy from narrow range consolidation.
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 narrow range breakout, where the NarrowestRangeSignal indicator detects the narrowest bar range within a specified period to generate a signal. Entry conditions involve placing a buy stop order above the range high plus an indent offset and a sell stop order below the range low minus an indent offset when the indicator fires, creating bracket stop orders on both sides. Exit conditions rely on a fixed take profit parameter for closing positions, with stop loss set on the opposite side of the range (buy stop SL below the low, sell stop SL above the high). Position sizing supports two modes: fixed lot and fixed percentage, where the percentage mode calculates lot size based on available free margin and account leverage. Money management includes lot validation against broker min/max limits and step normalization via CheckLotValue, but lacks independent risk control for stop loss sizing, and there is no trailing stop or break-even mechanism.
Strengths
- Clear and logical narrow range breakout strategy that captures momentum after low-volatility consolidation periods
- Reasonable OCO bracket order mechanism that automatically deletes the opposite pending order when one side triggers, avoiding dual-position risk
- Supports both fixed lot and fixed percentage position sizing modes, offering good flexibility
Weaknesses
- Lacks trailing stop and break-even mechanisms, so winning positions may give back significant profits before being stopped out
- Stop loss is placed at the opposite side of the range minus indent, which may result in stops that are too tight or too wide without dynamic ATR-based adjustment
- DeletePendingOrders uses a static variable for new bar checking that duplicates and potentially conflicts with CheckOrders logic, and creating a new CTrade object each tick is inefficient
Possible improvements
- Add ATR-based dynamic stop loss and trailing stop mechanisms to replace fixed indent and fixed take profit, making the strategy adaptive to different market volatility conditions
- Optimize code structure by declaring CTrade as a global variable to avoid repeated instantiation, and unify the new bar checking logic to prevent static variable conflicts between functions
Risk assessment
Overall risk: Medium
- Stop loss calculation is not robust enough; subtracting indent from the opposite range side may result in stops too tight and easily triggered by false breakouts
- No maximum position count limit or daily maximum loss control, so consecutive signals may cause frequent trading and capital loss
- Static prev_time variables in both DeletePendingOrders and CheckOrders may cause new bar detection to be out of sync, presenting a logic flaw
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
InpBarsInRange | 3 | Number of bars within narrow range |
InpCheckPeriod | 10 | Period to check for narrowest range |
InpIndent | 50 | Offset in points from high/low for pending orders |
InpTakeProfit | 500 | Take profit in points |
InpMmMode | FIXED_LOT | Money management mode: fixed lot or fixed percentage |
InpVolume | 1.0 | Trading volume (lots or percentage) |
Similar Breakout EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.