P
PipsGrowth
Back to Auto Trading Hub
MT5 / MQL5 track

MT5 EA for Breakout Strategy

Design a breakout Expert Advisor for MT5 with volatility compression, false-breakout filters, sessions, ATR stops, and robust testing.

Risk warning

Educational content only. Automated trading can lose money quickly. Backtests do not guarantee live results, and every bot should be demo-tested with realistic spread, commission, slippage, and news conditions before any live use. This is not financial advice.

Role of this page

MT5 Expert Advisor content focuses on native terminal execution, MQL5 structure, tester settings, broker symbol constraints, and live execution differences.

Who this is for

  • MQL5 EAs that must run inside MetaTrader 5 on a broker account or VPS.
  • Strategies needing MT5 Strategy Tester, optimization, forward testing, and terminal logs.

Not for

  • Python-only API trading systems that do not use the MT5 terminal.
  • Order-flow assumptions when the broker does not provide reliable Depth of Market.

Breakout EA logic

A breakout EA should define the range, trigger, confirmation, invalidation, and no-trade filters before any code is written. The common failure is chasing every range break without volatility or retest confirmation.

  • Build the range from a fixed session, Donchian channel, or structure box.
  • Require candle close, volatility expansion, or retest confirmation.
  • Use ATR or structure-based stops, not arbitrary points.

MQL5 implementation notes

Separate SignalEngine, RangeEngine, RiskEngine, ExecutionEngine, and OnTester criteria. Log every rejected setup so optimization does not hide weak assumptions.

  • Use input parameters for range session, ATR period, stop multiplier, max spread, and risk percent.
  • Check CTrade return codes and broker stop/freeze levels.
  • Validate with out-of-sample, walk-forward, and Monte Carlo tests.

Practical examples

  • Breakout EA: define range, wait for candle close, confirm volatility, place order, manage ATR stop.
  • Risk wrapper: reject trades when spread, stop level, margin, daily loss, or session rules fail.

Checklist

  • Inputs: symbol, magic number, lot model, stop model, session window, spread/slippage caps.
  • Execution: fill policy, trade return codes, retry rules, partial close support, hedge/netting account type.
  • Logging: signal state, rejected-trade reason, order ticket, spread, slippage, and modification result.

Validation plan

  • Run MT5 backtests with realistic spread/commission and compare fixed spread versus variable spread behavior.
  • Use forward optimization periods and demo logs to check tester-to-live differences.

Implementation notes

  • Keep OnTick signal evaluation separate from order execution and risk gates.
  • Use OnTester or custom criteria only after the baseline logic is stable.

Developer / IDE prompt

Generate an MQL5 EA plan only. Include inputs, OnInit checks, OnTick flow, CTrade execution checks, stop/freeze-level handling, tester settings, optimization ranges, forward-test plan, and all no-trade filters. Do not add Python unless explicitly requested as an external research layer.

Next step

Turn these concepts into a complete bot logic plan with the strategy builder wizard.

Open Strategy Builder
MT5 EA for Breakout Strategy