The bollinger bands indicator draws the classic three lines and nothing more. Mid is a simple moving average over BbPeriod bars. Upper and Lower sit a multiple of the standard deviation either side of it, so they widen and narrow as the market does.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 3: Mid, Upper, Lower |
| Alerts | popup, push notification, email, sound |
| Inputs | 8 |
What the Bollinger Bands Indicator draws on the chart
Mid is the simple moving average of the closes over BbPeriod bars.
Upper sits BbMult standard deviations above Mid.
Lower is the same distance below it.
Nothing else appears. This build declares three line plots and no markers.
- Mid: line, goldenrod, width 2
- Upper: line, dodger blue, width 2
- Lower: line, dodger blue, width 2

How the Bollinger Bands Indicator calculates its values
The middle line
One call to the platform averaging routine gives Mid, using simple mode over BbPeriod closes. There is nothing weighted or exponential about it.
That choice matters more than it looks. The deviation measured next is measured against this same average, so changing the mode would change both lines.
Band width from deviation
A second call returns the standard deviation of the closes over the same window and the same averaging mode. Multiplying it by BbMult gives the distance to each band.
Standard deviation grows when closes scatter and shrinks when they cluster. That is why the bands squeeze in quiet conditions and flare after a shock.
Warm-up
The loop stops BbPeriod plus one bar short of the oldest candle, since neither the average nor the deviation means anything on a partial window.
So the left edge of a fresh chart carries no lines at all.
How to read the signals
Price at Upper means the recent closes have stretched two deviations above their own average, not that price is too high.
A squeeze is the bands closing in, which says the last BbPeriod closes have clustered tightly.
Mid doubles as a reference line in its own right, since it is a plain 20 bar average.
Bands react after volatility changes, never before it.
Alert channels in this build: popup, push notification, email and sound.
Alerts cover popup, push, email and sound. This build carries no once-per-bar guard, so a condition can alert more than once while a bar is still forming.
Every Bollinger Bands Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
BbPeriod |
BbPeriod sets the window for both the average and the deviation. It defaults to 20, the length the technique was published with. | 20 |
BbMult |
BbMult is how many deviations each band sits from Mid. It defaults to 2.0, which covers most closes in a normally distributed sample. | 2.0 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
EnableAlerts gates the message block and defaults to true. | on |
EnablePopup |
EnablePopup shows the MT4 dialog and defaults to true, so it is the one channel active out of the box. | on |
EnablePushNotify |
(see inputs panel) | off |
EnableEmail |
(see inputs panel) | off |
EnableSound |
(see inputs panel) | off |
SoundFile |
(see inputs panel) | alert.wav |

Settings that fit your chart
The screenshot uses EURUSD H1. Twenty bars on H1 covers most of a trading day, which is why the default travels so widely. On daily charts the same window becomes a month of context. Below M15 the deviation reacts to individual candles and the bands flare on single spikes.
When the Bollinger Bands Indicator fails
A touch of Upper is not a sell. In a trend price can walk the band for many bars while the average climbs underneath it.
Standard deviation assumes closes scatter around a mean, and a trending market breaks that assumption for as long as the trend runs.
The bands widen after a shock rather than before one, so they offer no warning of the move that stretched them.
Both lines depend on the same BbPeriod, so there is no way to measure deviation over a different window than the average.
Copy the compiled Bollinger Bands Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Download the Bollinger Bands Indicator for MT4 and MT5
The zip holds the compiled Bollinger Bands Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
What does BbMult 2.0 actually cover?
Two standard deviations either side of Mid. In a normally distributed sample that spans most observations, which is where the familiar description comes from. Market closes are not normally distributed, so treat two deviations as a useful convention rather than a fixed expectation about how often price stays inside.
Does BbPeriod change the deviation as well as the average?
Yes, both. The same window feeds the averaging call and the deviation call, so raising BbPeriod to 50 gives a slower Mid and a deviation measured over 50 closes. The two cannot be set apart in this build.
Why do the bands squeeze before a big move so often?
A squeeze only reports that recent closes clustered tightly. Quiet stretches often precede active ones, so the pattern shows up frequently, but the bands are describing what already happened rather than forecasting what comes next.
Is Mid the same as a plain 20 bar moving average?
Yes. Mid is a simple moving average of the closes over BbPeriod, with no weighting applied. You can read it exactly as you would read that average on its own, and the bands add the deviation context around it.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Bollinger Bands Indicator as one input. Always backtest before trading live.
Next, category: this is part of our Volatility collection. Also, truly, browse more Volatility for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- The core method is documented in High Low Bands at StockCharts ChartSchool.
- Additional market context is at Price action trading on Wikipedia.
