Bollinger Breakout EA MT5 — No Code
Can I build a Bollinger Band breakout EA for MT5 without coding?
Yes. In AlfaTactix Strategy Builder, write the Buy rule on Step 3 — Entry rules as one line: Buy when Close crosses above BB upper(20, 2) (Bollinger Bands with Length 20, Width (standard deviations) 2). Write the Sell rule the other way round: Close crosses below BB lower(20, 2). Add a Stop loss on Step 5 and the position size on Step 6, press Save strategy in Step 7, then Get the code, compile once in MetaEditor, and backtest on H1 EURUSD with Every tick in the Strategy Tester.
Optional squeeze first: add a second line in the group All of these: BB BandWidth at or below its lowest of the last 120 bars, with Happened within the last N bars.
Disclosure: This tutorial uses AlfaTactix Strategy Builder. For the full no-code platform overview, see Build EA Without Coding. For Bollinger Bands indicator theory (squeeze, %B, band walk), see the Bollinger Bands Academy guide. For a mean-reversion counterpart, see RSI Overbought/Oversold EA — No Code.
Related guides: Create/Edit MT5 EA · EA Risk Management · Backtest in Strategy Tester · EA Strategy Library
What Is a Bollinger Band Breakout EA?
A Bollinger Band breakout Expert Advisor automates one of the most popular volatility expansion systems in trading:
| Signal | Rule |
|---|---|
| Buy (long) | Price was inside the bands and breaks above the upper Bollinger Band with momentum |
| Sell (short) | Price was inside the bands and breaks below the lower Bollinger Band with momentum |
Bollinger Bands plot three lines: a middle band (typically SMA 20), an upper band (middle + 2 standard deviations), and a lower band (middle − 2 standard deviations). When volatility contracts (squeeze), bands narrow; when price explodes out of the range, a breakout EA enters in the direction of the escape.
The EA runs on every tick or bar in MetaTrader 5 via OnTick() [1]. You do not watch charts manually — the platform executes when your Bollinger condition fires.
Why traders search for this: Bollinger breakouts capture post-squeeze moves and trend continuations. Tutorials usually show hand-written MQL5 with iBands() [2]. This guide shows the same logic in Strategy Builder, with the settings and sentence-builder options that matter for Bollinger Bands.
Classic BB Settings and When It Works
| Setting | Starter value | Notes |
|---|---|---|
| Length | 20 | John Bollinger default; 14 = faster, 50 = slower |
| Width (standard deviations) | 2 | Range 0.1–5; 2.5 = wider bands, fewer touches |
| Middle line average | SMA | EMA middle band reacts faster |
| Price | Close | High/Low for wick-sensitive systems |
| Timeframe | H1 (forex majors) | M15 = more signals; H4 = cleaner breakouts |
| Symbol | EURUSD, GBPUSD | Liquid pairs; spread matters on tight stops |
| Squeeze window | within the last 5 bars | Optional: BandWidth at its lowest of the last 120 bars happened within the last 5 bars |
Works best: After a squeeze (narrow bands) or when volatility expands — trending sessions on liquid forex (London / New York).
Struggles in: Choppy sideways markets — price pokes outside bands and reverses. Mitigate with Step 4 Market sessions or Spread limit, a squeeze-first line in All of these, or a trend filter from the MA Crossover EA guide.
For indicator background (squeeze, %B, band walk), read the Bollinger Bands Academy guide.
Bollinger Bands Parameters in Strategy Builder
When you pick Bollinger Bands in the indicator picker (tab Indicator) on Step 3 — Entry rules, its settings open:
| Setting | Range / options | Default | What it does |
|---|---|---|---|
| Length | 2 – 200 | 20 | Lookback bars for the middle band |
| Width (standard deviations) | 0.1 – 5 | 2 | Multiplier for the upper/lower band distance from the middle |
| Price | Open … (O+H+L+C)/4 (7 choices), under More settings | Close | Price series used in the calculation |
| Middle line average | SMA, EMA, under More settings | SMA | Average type of the middle band |
Pick the Timeframe in the picker too, and use Line to choose which of the five lines you mean: middle, upper, lower, %B or BandWidth.
Tip for breakout EAs: Length 20, Width (standard deviations) 2, Middle line average SMA, Price Close — the industry default. Choose the same Timeframe as your trading timeframe in Step 2 (e.g. H1).
Bollinger Bands Condition Types Explained
In Step 3 every condition is one sentence: What to watch · How they compare · Compare with. In the Buy rule it starts with Buy when. Below is how each Bollinger idea is built.
1. Compare
Under What to watch pick Close (tab Price) or a Bollinger line (tab Indicator, then Line), choose is above, is below, is at or above or is at or below, and under Compare with pick another line, a Number or a price.
Use case: “Only buy breakouts when Close is above BB middle(20, 2)” — a trend filter in the group All of these next to the breakout line.
2. Price crosses a band
Choose the operator crosses above or crosses below. It is true only on the bar where the left side passes the right side.
Classic breakout alternative:
| Rule | Sentence |
|---|---|
| Buy rule | Close crosses above BB upper(20, 2) |
| Sell rule | Close crosses below BB lower(20, 2) |
Use case: “Price crosses above the upper band” — the whole breakout entry in one line.
3. Squeeze
A squeeze is a narrow band width, often before an explosive move. Two ways to build it:
- Step 4 quick filter: Trade only after a quiet squeeze (Bollinger BandWidth at its lowest of the last 120 bars).
- Step 3 line: BB BandWidth is at or below the lowest BB BandWidth of the last 120 bars (tab Calculation, Lowest of).
Use case: “BandWidth at its lowest of the last 120 bars, Happened within the last 5 bars, and Close crosses above BB upper” — enter only after the compression releases.
4. Breakout
Price closes outside the band after being inside — the core condition for this EA. In v2 it is the crossing line from section 2: Close crosses above BB upper(20, 2) for Buy, Close crosses below BB lower(20, 2) for Sell.
To ask for “was in a squeeze recently”, set Time window on the squeeze line to Happened within the last N bars (the catalog example uses 5 bars). “Has been true for N bars in a row” is not offered with crossings.
Use case: Post-squeeze momentum entries; combine with the squeeze or BB BandWidth is rising for higher quality signals.
5. Candle patterns
The tab Patterns and the operator appears are for candle patterns. Most BB breakout EAs do not need them.
6. Rising / falling (slope)
Require the middle band to rise or fall: choose is rising or is falling on BB middle, with Over how many bars and Minimum change (0 = any rise or fall).
Use case: “Close crosses above BB upper and BB middle is rising over 5 bars” — only trade breakouts aligned with the band direction.
7. BandWidth expanding or contracting
Pick the line BandWidth and the operator is rising (volatility increasing) or is falling (volatility decreasing), with Over how many bars.
Use case: “BB BandWidth is rising and Close crosses above BB upper” — enter when volatility expands, not during contraction.
8. Percent B (%B)
Pick the line %B (price position within the bands) and compare it with a Number. The catalog example is “BB %B is below 0” (price below the lower band).
Use case: “%B is above 1” means price is above the upper band; combine with All of these / Any of these as needed.
Combining conditions on Step 3
Lines sit in groups: All of these (every line must be true) or Any of these (one is enough). Must not be true turns a line around. Add lines with Add a condition and groups with Add a group — same idea as in Build EA Without Coding. Example: group All of these with “BandWidth at its lowest of the last 120 bars, within the last 5 bars” and “Close crosses above BB upper”.
Build the BB Breakout EA Step by Step
Workflow: 7 steps in Strategy Builder demo. We detail what matters for a classic BB 20/2 breakout EA.
Step 1 — Information and platform
- Name: e.g.
BB Breakout H1 EURUSD - Description: optional
Step 2 — Timeframes
- Add H1 as the trading timeframe (the lowest one in the list). In Step 3, choose H1 in the Timeframe selector of the Bollinger Bands.
- Optional: add up to two higher timeframes as context for a trend filter (Advanced MTF Filters).
Step 3 — Entry rules (core)
- In the Buy rule, under What to watch, open tab Price and choose Close.
- Under How they compare, choose crosses above.
- Under Compare with, open tab Indicator and choose Bollinger Bands, Line upper:
- Length: 20
- Width (standard deviations): 2
- Price: Close (under More settings)
- Middle line average: SMA (under More settings)
- Timeframe: H1
- Write the Sell rule the other way round (Write the sell rule yourself): Close crosses below BB lower(20, 2).
Optional squeeze first on Buy: add a second line in All of these: BB BandWidth is at or below the lowest BB BandWidth of the last 120 bars, Happened within the last 5 bars.
Step 4 — Filters (optional)
Examples: Market sessions (London/New York), a Spread limit, or Market conditions such as the quick filter Skip quiet markets. See Advanced EA MTF & Filters.
Steps 5 and 6 — Exits, risk and money management
Minimum for a testable EA:
| Setting | Suggestion |
|---|---|
| Position size | Fixed lots 0.01 on demo, or Risk per trade (% of the account) 1 % |
| Stop loss | Unit Pips or ATR multiple (breakouts need room beyond the band) |
| Take profit | Optional; many BB EAs trail or exit on the opposite breakout |
| Most trades open at the same time | 1, to avoid overlapping positions |
Full reference: EA Risk Management.
Step 7 — Review and save
Read the Check list, fix any problem it shows, then press Save strategy.
Export, Compile, and Backtest
- In Step 7, after Save strategy, press Get the code and choose the MetaTrader 5 code.
- Copy to
MQL5/Experts, compile (F7) in MetaEditor [3]. - Strategy Tester: Every tick, realistic spread, 6–12 months data on H1 EURUSD.
- Forward test on Demo before live.
If OrderSend fails with 10016, see Invalid Stops.
The generated code writes the Bollinger calculation out itself and does not call iBands() — see Build EA Without Coding for the full workflow.
Improvements: Filters and Risk
| Problem | Builder lever |
|---|---|
| False breakouts in ranges | A squeeze-first line in All of these; Step 4 Market sessions |
| Entering during contraction | BB BandWidth is rising in All of these with the cross |
| Counter-trend breakouts | Add trend filter (see MA Crossover EA) |
| Spread eats profit | Step 4 Spread limit; test on ECN/low-spread symbol |
| Over-trading | Step 6 Entries per day; keep Most trades open at the same time at 1 |
| Late entries | Use is above BB upper instead of crosses above (more entries, and some are late) |
Next Steps
- Bollinger Bands Academy guide — squeeze, %B, band walk, and chart examples
- Build EA Without Coding — full 7-step builder tour
- RSI Overbought/Oversold EA — No Code — mean-reversion counterpart
- Moving Average Crossover EA — No Code — trend filter partner
- Donchian Channel and breakout EA — channel breakout (Turtle-style)
- Advanced EA MTF & Filters — session, spread, multi-timeframe
Volatility check: BB breakouts fail in dead ranges. Note bandwidth on your chart last week — if bands were flat, expect false breaks. In the live demo, set Length 20 and Width (standard deviations) 2 and compare one month of breakouts to your manual marks before you get the code.
References: MQL5 iBands [2], MetaTrader 5 Strategy Tester [4].

