Skip to content

Free MT5 Expert Advisor

Bollinger Squeeze Breakout EA

MT5 Expert Advisor that waits for a Bollinger bandwidth squeeze, then trades the first close outside the bands with an ATR stop.

Breakoutv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Stop-loss on every trade
Strategy
Buys the first close above the upper Bollinger Band and sells the first close below the lower band, but only when bandwidth was near its lowest level of recent history just before the breakout.
Risk model
1% of balance per trade (configurable), ATR-based stop-loss on every order, one position at a time

What it does

Quiet markets tend to be followed by active ones. Bollinger Squeeze Breakout EA measures how narrow the Bollinger Bands are compared with their own recent history, and when they have been unusually tight, it trades the first decisive close outside the bands.

How it works

Bandwidth is (upper band − lower band) ÷ middle band, using a 20-period, 2-deviation Bollinger Band. On each new bar:

  1. The EA finds the lowest bandwidth of the last 120 closed bars (excluding the breakout bar).
  2. A squeeze exists if any of the 5 bars before the breakout bar had a bandwidth no more than 1.10 × that lowest value.
  3. Buy: the last closed bar closed above the upper band and the bar before it did not.
  4. Sell: the last closed bar closed below the lower band and the bar before it did not.
  5. Stop-loss: 2 × ATR(14) from the entry price. Take-profit: 2 × the stop distance (set to 0 to rely on the exits only).

With the middle-band exit enabled, an open buy is closed when a bar closes below the middle band, and an open sell when a bar closes above it. This cuts breakouts that fail quickly. The page on volatility covers why calm periods often precede larger moves.

How to use it

Squeezes are rare by design, so expect long quiet periods. The EA suits instruments that trend after consolidation, such as major pairs around session opens, gold, and stock indices. H1 is a balanced starting point. The trailing stop can be switched on if you prefer to let trends run instead of using a fixed target.

Settings

InputDefaultWhat it changes
Bollinger period / deviation20 / 2.0Band shape
Bars used to find the lowest bandwidth120Squeeze reference window
Squeeze recent bars5How fresh the squeeze must be
Squeeze factor1.10Tolerance above the lowest bandwidth
Stop-loss (x ATR)2.0Stop size
Reward:risk target2.0Take-profit, 0 disables it
Middle-band exittrueEarly exit for failed breakouts
Risk per trade / Fixed lots1.0% / 0Position sizing
Max spread / Trading hours30 / 7–20Filters
Break-even / Trailingon / offStop management

Limitations

The direction of a squeeze breakout is unknown in advance, and false breaks are common: price may close outside the band once and then reverse. Squeezes before major news can resolve with a gap that jumps the stop. A fixed 120-bar reference means the definition of "narrow" depends on the timeframe.

Before you run it live

Run the Strategy Tester across different market phases (trending and ranging years), then a demo account. Check spreads around session opens, where breakouts often happen, and set the risk per trade to a level you can sustain through a run of losses. Past behavior does not guarantee future results.

Key inputs

Key inputs of Bollinger Squeeze Breakout EA
InputDefaultDescription
Bollinger period20Bars used for the bands.
Bars used to find the lowest bandwidth120History that defines what counts as unusually narrow.
A squeeze must occur within this many bars before the breakout5How recent the squeeze must be.
Squeeze = bandwidth <= lowest bandwidth x this factor1.10Tolerance above the lowest bandwidth.
Stop-loss distance (x ATR)2.0Stop size as a multiple of ATR(14).
Take-profit as a multiple of the stop (0 = none)2.0Reward-to-risk target.
Close when a bar closes back across the middle bandtrueExits a failed breakout early.

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