Custom Bollinger Bands Indicator: Bands With a Shift Input

Written by Dominic Walsh · Published · Last updated

The custom bollinger bands indicator gives you the standard three lines plus two things a plain build leaves out: a shift input that moves the whole construction along the chart, and markers for the close that crosses back through a band.

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 5: BB Middle, BB Upper, BB Lower, BUY, SELL
Alerts popup
Inputs 5

What the Custom Bollinger Bands Indicator draws on the chart

BB Middle is the average at the centre of the construction.

BB Upper and BB Lower sit DeviationMult deviations either side.

BUY marks a close crossing back up through the lower band.

SELL marks the mirror crossing through the upper one.

  • BB Middle: line, dodger blue, width 1
  • BB Upper: line, tomato, width 1
  • BB Lower: line, medium sea green, width 1
  • BUY: arrow, lime, width 2, arrow code 233
  • SELL: arrow, red, width 2, arrow code 234
EURUSD H1: the custom bollinger bands indicator marking BUY as price closes back through BB Lower.
EURUSD H1: the custom bollinger bands indicator marking BUY as price closes back through BB Lower.

How the Custom Bollinger Bands Indicator calculates its values

The three lines

Three calls to the platform band routine return the middle, upper and lower values over LookbackPeriod at DeviationMult.

AppliedShift passes straight through to those calls, which is what moves the whole construction forward or back along the chart.

What the shift is for

Shifting the bands lets you line them up against price with a deliberate offset, which some traders use to compare where price sits against where the band was.

It defaults to 0, so out of the box this behaves exactly like a standard band set.

The crossing test

The marker logic compares the previous close and the current close against the band values. A close on one side followed by a close on the other qualifies.

ArrowOffsetPts then spaces a marker from its candle by eight points, which is tight enough to sit close to the bar it refers to.

How to read the signals

The bands behave exactly as a standard set when AppliedShift stays at 0.

A marker is a crossing rather than a touch, so price has to close on both sides.

Band width changes every bar, so the level being crossed is not a fixed price.

BB Middle doubles as a plain average of the same length.

Alert channels in this build: popup, one message per closed bar.

The one alert channel here is the MT4 popup. A bar time check runs first, so a crossing raises one dialog per closed bar.

Every Custom Bollinger Bands Indicator input

Core settings

Setting What it does Default
LookbackPeriod Bollinger period. LookbackPeriod is the window for the average and the deviation. It defaults to 20. 20
DeviationMult Standard deviation multiplier. DeviationMult is how many deviations each band sits from the middle, 2.0 by default. 2.0
AppliedShift Bands horizontal shift. AppliedShift moves the whole construction along the chart. It defaults to 0, which matches a standard build. 0

Display settings

Setting What it does Default
ArrowOffsetPts Arrow vertical offset (points). ArrowOffsetPts spaces a marker from its candle, 8 points by default, which is deliberately tight. 8

Alert settings

Setting What it does Default
EnableAlerts Enable one-alert-per-bar. on
Inputs panel for the custom bollinger bands indicator showing LookbackPeriod and AppliedShift.
Inputs panel for the custom bollinger bands indicator showing LookbackPeriod and AppliedShift.

Settings that fit your chart

The screenshot uses EURUSD H1. A twenty bar window at two deviations is the classic setting and behaves predictably on any liquid instrument from M15 upward. On faster charts the deviation reacts to single candles and the bands flare, which produces crossings that mean little.

When the Custom Bollinger Bands Indicator fails

Crossing back through a band is common in a trend, so plenty of markers appear against moves that continue.

AppliedShift moves the bands without changing what they measure, so a shifted band is easy to misread as a forecast.

An eight point offset is tight, and on a volatile instrument the markers can sit inside the candle wicks.

The bands widen after volatility arrives rather than before it, so the level a close has to clear keeps moving.

Copy the compiled Custom 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 Custom Bollinger Bands Indicator for MT4 and MT5

The zip holds the compiled Custom 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.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What does AppliedShift actually move?

The whole band construction along the chart, forward or back. It passes straight through to the underlying calls, so the maths is unchanged and only the position moves. At the default of 0 this build behaves exactly like any standard band set.

Is a BUY marker a touch of the lower band?

No, it is a crossing. The previous close has to finish on one side of the band and the current close on the other. A bar that trades through the band and closes back inside never qualifies, which filters out a lot of noise.

Should I widen ArrowOffsetPts from 8?

On a volatile instrument, yes. Eight points is tight enough that markers can land inside long wicks. Widening it moves them clear of the candle without touching the crossing test, which reads closes and band values only.

Does DeviationMult 2.0 make crossings rare?

It sets how far price has to travel before it can close outside a band, so raising it towards 3.0 makes both excursions and crossings noticeably rarer. Lowering it towards 1.5 fills the chart with markers, most of them inside ordinary movement.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Custom Bollinger Bands Indicator as one input. Always backtest before trading live.

Category: this is part of our Volatility collection. Next, plainly, yet, browse more Volatility for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment