Skip to content

Free MT5 Expert Advisor

Inside Bar Breakout EA

MT5 Expert Advisor that brackets an inside bar with stop orders at the mother-bar extremes, with the stop at the opposite extreme and an expiry.

Price actionv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Stop-loss on every trade
Strategy
After an inside bar closes, it places a buy stop above the mother-bar high and a sell stop below the mother-bar low. The first order to fill cancels the other, and unfilled orders expire after a set number of bars.
Risk model
1% of balance per trade (configurable), stop-loss at the opposite mother-bar extreme on every order, one position at a time

What it does

An inside bar is a candle whose whole range sits inside the previous candle, called the mother bar. It shows a pause in which neither side pushed price beyond the earlier extremes. Inside Bar Breakout EA places stop orders on both sides of the mother bar and lets the market choose the direction.

How it works

On every new bar:

  1. Pattern: the last closed bar's high is below the previous bar's high and its low is above the previous bar's low.
  2. Size filter: the mother bar's range must be between 0.6 and 2.5 × ATR(14).
  3. Orders: a buy stop at mother high + buffer and a sell stop at mother low − buffer, where the buffer is 0.05 × ATR.
  4. Stops: the buy stop's stop-loss sits at the sell entry and the sell stop's stop-loss sits at the buy entry, so each trade risks the full mother-bar range plus two buffers.
  5. Target: 1.5 × that stop distance.
  6. One trade: when either order fills, the other is deleted immediately.
  7. Expiry: unfilled orders are deleted after 3 bars, and at the end of the trading hours.

Expiry is handled by the EA from each order's placement time, so it works even with brokers that do not accept specified expiry times. See candlestick patterns for more on reading bar structure.

How to use it

Inside bars on H4 and D1 carry more meaning than on low timeframes. If you have a directional view, disable one side so only the buy stop or only the sell stop is placed. You can preview the risk of a mother bar's range with the Position Size Calculator.

Settings

InputDefaultWhat it changes
Entry/stop buffer (x ATR)0.05Distance beyond the mother bar
Min / Max mother-bar range (x ATR)0.6 / 2.5Size filter
Reward:risk target1.5Take-profit, 0 disables it
Order expiry (bars)3Lifetime of pending orders
Place buy stop / sell stoptrue / trueDirection choice
ATR period14Volatility for filters and management
Risk per trade / Fixed lots1.0% / 0Position sizing
Max spread / Trading hours30 / 7–20Filters
Break-even / Trailingon / offStop management

Limitations

Breakouts from inside bars often fail and reverse, and the stop at the opposite extreme makes each loss relatively wide. In a fast gap both orders could fill before the EA reacts; it then closes the newer position, which can cost a spread or more. Pending orders can fill with slippage.

Before you run it live

Test it in the Strategy Tester with real-tick data, since pending-order fills depend on intrabar movement, then run it on a demo account. Check that your broker allows stop orders at the distances used and keep the risk per trade small. Past behavior does not guarantee future results.

Key inputs

Key inputs of Inside Bar Breakout EA
InputDefaultDescription
Entry/stop buffer beyond the mother bar (x ATR)0.05Small distance added beyond the mother-bar high and low.
Minimum mother-bar range (x ATR)0.6Ignores tiny mother bars.
Maximum mother-bar range (x ATR)2.5Ignores mother bars that would need a very wide stop.
Take-profit as a multiple of the stop (0 = none)1.5Reward-to-risk target.
Delete unfilled orders after this many bars3Expiry of the pending orders.
Place the buy stop / Place the sell stoptrue / trueTrade both directions or only one.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors