Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Bollinger Bands, BB - MetaTrader 4 Script | Forex Indicator Download - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

Bollinger Bands, BB - indicator for MetaTrader 4

Bollinger Bands® (BB) are similar to envelopes. The only difference is that envelopes are drawn a fixed distance (%) away from the moving average, while Bollinger Bands are drawn a certain number of standard deviations away from the moving average.

Standard deviation is a measure of volatility, so Bollinger Bands adjust themselves based on market conditions. The range widens when the market becomes more volatile and shrinks during less volatile periods.

Bollinger Bands, BB - indicator for MetaTrader 4

Bollinger Bands, BB

Bollinger Bands are usually plotted on price charts, but can also be added to indicator charts. As is the case with envelopes, Bollinger Bands interpretation is based on the fact that prices tend to stay between the top and bottom lines of Bollinger Bands. A distinctive feature of the Bollinger Bands indicator is that its width changes in response to price fluctuations. During periods of large price changes (i.e. high volatility), the bands widen, leaving a lot of room for price swings. During periods of stagnation or low volatility, the bands shrink, keeping prices within their limits.

The following are characteristics unique to Bollinger Bands:

This last observation is useful for forecasting price guidance.

Bollinger Bands consists of three lines. The middle line (ML) is the usual moving average.

ML = SUM (Close Price, N) / N = SMA (Close Price, N)

The top line (TL) is the same as the middle line, but with a certain amount of standard deviation (D).

TL = ML + (D * standard deviation)

The bottom line (BL) is the midline shifted downward by the same amount of standard deviations.

BL = ML — (D * standard deviation)

Standard deviation = SQRT (SUM ((Closing price - SMA (Closing price, N))^2, N)/N)


It is recommended to use the 20-period simple moving average as the midline and draw the top and bottom lines two standard deviations away from it. In addition, moving averages with less than 10 periods have little impact.

Technical specifications

A complete description of Bollinger Bands can be found in the Technical Analysis: Bollinger Bands section


Attachment download

📎 bands.mq4 (4.9 KB)

📎 movingaverages.mqh (8.85 KB)

Source: MQL5 #7818

Verification code Refresh