Skip to content
All library documents

Daily Breakout EA Using Previous-Day Highs and Lows

Article MQL5 code base

Summary

This MetaTrader 5 expert advisor places a buy stop above the previous daily bar’s high and a sell stop below its low, with an optional price offset. It removes its existing pending orders when it begins a new trading day, then submits the new pair if trading is allowed by the configured time and spread checks. Each order receives a stop loss, while no take profit is set. If a position moves favorably, the EA trails its stop to maintain a configured distance from the current price.

The code also includes configurable lot sizing, an optional balance-risk setting, and checks for volume, margin, stop distance, and broker freeze levels. The document describes implementation details rather than providing backtest results or evidence of profitability. Its safeguards and scheduling behavior depend on broker settings and server time; the shown time condition checks the start hour but does not visibly enforce the configured end hour. The supplied excerpt is incomplete, so some behaviors cannot be assessed from it.

Key ideas

  • The EA brackets the previous daily bar with buy stop and sell stop orders.
  • It deletes matching pending orders and resets the breakout entries at the start of a new daily bar.
  • Initial stop losses are set without take-profit targets, and open positions use a trailing stop.
  • Spread, margin, volume, stop-distance, and freeze-level checks are included, but no performance evidence is provided.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.