How to build an opening range breakout EA for MT5 without coding
Build an opening range breakout Expert Advisor for MetaTrader 5 or 4 from blocks: define the range, trade the break once a day, size risk, and backtest it on your own M1 data.
Updated 5 November 2026
The opening range breakout (ORB) is one of the simplest intraday strategies to automate: mark the high and low of the first minutes of a session, then trade the first clean break. This guide builds one in QuantForge with no code, tests it on your own data, and exports it for MetaTrader 5 or 4.
The rules
- Build the range from 08:00 to 08:15 server time (change it to your session).
- Buy when price breaks above the range high by at least 2 pips; sell when it breaks below the low by 2 pips.
- Skip days when the range is wider than 40 pips: a wide range means the move has already happened.
- Stop looking for entries at 12:00.
- One trade per day, risking 1% of equity, with the stop at 20 pips and the target at 40.
Build it
Create a new project, choose MT5 (or MT4), and on the onTick canvas add:
- Opening range breakout up. Set the start time to 08:00, the length to 15 minutes, the margin to 2 pips, the maximum width to 40 pips and the until time to 12:00. Its YES output fires on every tick while price is above the range, so the next block limits it.
- Trades today (or Once a day) after it, so only one trade is taken per day.
- Buy Now (Market Order) with risk % sizing: 1%, stop loss 20 pips, take profit 40 pips.
- Repeat with Opening range breakout down and Sell Now for the short side, sharing the same daily limit if you want only one trade per day in total.
Optional, but usually worth testing:
- Max Spread Filter before the entry, so a news spike with a wide spread doesn’t trigger the order.
- Move to Break-Even at +20 pips on the onTick canvas, so a winner can’t turn into a loss.
- Close Trades after a Time window at 20:00, if you don’t want to hold overnight.
Link the range start, length and stop to EA inputs (see Inputs) so you can tune them later without editing blocks.
Test it
Import M1 history for the symbol from your own terminal (see importing price history), open the Strategy Tester, choose the 1-minute OHLC model and a year or more of dates. Breakouts are sensitive to spread and slippage, so set realistic values: your broker’s commission and 0.5 to 1 pip of slippage.
Press play and jump to a few trading days: the chart shows where the range was broken, and the canvas shows which blocks passed. Check the report’s box of warnings, then look at:
- Monthly returns: ORB strategies often make most of their profit in volatile months. A long flat stretch is normal; a slow steady loss in quiet months is a cost to accept or filter.
- Average loss vs average win: with a 1:2 risk-reward the strategy can be profitable with a win rate around 40%, but not much lower once costs are included.
On Studio, optimise the range length and the stop with a forward test, and run a Monte Carlo analysis on the trades before you trust the drawdown.
Export it
Use Export for the .mq5 (or .mq4) source, or download the compiled file on Pro. Attach it to a chart of the symbol you tested, run it on a demo account first, and compare a few days of trades with the backtest.
Want to start from a tested version? The London Open Breakout template uses pending orders around the 07:00 price instead of a range, and shows its two-year EURUSD figures.
Frequently asked questions
What is an opening range breakout?
The opening range is the high and low price of the first minutes of a session, for example 08:00 to 08:15 server time. A breakout strategy buys when price breaks above the range high and sells when it breaks below the low, betting that the first move of the session continues.
Which time should I use for the range?
Use the open of the session you trade, in your broker's server time. Many forex brokers run on GMT+2 or GMT+3, so the London open (08:00 London time) is usually 10:00 server time. Check your broker's server clock in MetaTrader's Market Watch.
Does it work on MT4?
Yes. Build the strategy once and export it as MQL4 or MQL5.
Build your first EA today
The free plan includes three projects, backtests on H1 to D1 over a year, MQL4/MQL5 export and the converter.