Skip to content
FXNook HubBeta

Alex / ATR Bands (Keltner Channel) Indicator for MT5

MetaTrader 5IndicatorMITCompiled · build 6333
AlexFirst version.build 6333v1.06 hours ago1 version
  • FXN_AtrBands.mq5First version.7 KB
  • FXN_AtrBands.ex5Compiled by the Lab with MetaEditor build 633319 KB
README

Overview

Keltner-style ATR bands: a moving average of your choice with upper and lower bands set a multiple of ATR away, for trend and volatility context.

ATR Bands draws a moving average with an upper and a lower band placed a set number of Average True Ranges away. It works like a Keltner Channel: the bands widen when the market becomes more volatile and narrow when it calms down, so you can judge whether a move is stretched, where a volatility-based stop could sit, and which way the average is pointing.

How it works

  • Middle line: a moving average of the chosen price. SMA is the plain average of the last N prices, EMA uses 2 / (N + 1) as weight, SMMA (smoothed) uses (previous x (N - 1) + price) / N, and LWMA gives the newest bar the largest weight. EMA and SMMA start from an SMA seed.
  • ATR: Wilder's Average True Range over its own period, seeded with a simple average.
  • Bands: upper = MA + multiplier x ATR and lower = MA - multiplier x ATR.

Only the newest bar is recalculated on each tick; the full history is worked out once when the indicator loads.

Inputs

InputDefaultWhat it does
MA period20Number of bars in the middle moving average.
MA typeEMASMA, EMA, SMMA or LWMA.
Applied priceClosePrice used for the average (close, open, high, low, median, typical, weighted).
ATR period14Number of bars in the ATR.
Multiplier2.0Band distance in ATRs.
Band colourSteel blueColour of the upper and lower bands.
Middle colourGoldenrodColour of the moving average.
Show middletrueShows or hides the middle line (its values stay available to iCustom).

How to use it

  1. In MetaTrader choose File > Open Data Folder.
  2. MT4: copy FXN_AtrBands.mq4 into MQL4/Indicators. MT5: copy FXN_AtrBands.mq5 into MQL5/Indicators.
  3. Restart the terminal, or right-click Indicators in the Navigator and choose Refresh. If the indicator does not appear, open the file in MetaEditor and press F7 to compile it.
  4. Drag the indicator onto a chart, adjust the inputs and press OK.

Start with EMA 20, ATR 14 and multiplier 2.0, a common Keltner setting. For a tighter channel use 1.5; for wider stop references try 2.5 or 3.0. Typical uses: a close outside the band in the direction of the average's slope as a sign of momentum, the middle line as a pullback area in a trend, or the opposite band as a reference for a stop.

Good to know

  • Forming bar: the values on the current bar change with price until it closes. Closed bars do not change.
  • The ATR is calculated inside the indicator with Wilder smoothing, so it matches the standard ATR indicator.
  • Unlike Bollinger Bands, the band width follows the average true range, not the standard deviation of closes, so it reacts less to a single large close.
  • Price outside a band is not a signal by itself; in strong trends price can ride along one band for a long time.
  • Buffers for iCustom: 0 upper, 1 middle, 2 lower. Works on any symbol and timeframe. It does not trade.

Trading carries risk. Test on a demo account first; past results do not predict future results.

At a glance

What it is
A free Indicator for MetaTrader 5, written in MQL5.
What it does
Keltner-style ATR bands: a moving average of your choice with upper and lower bands set a multiple of ATR away, for trend and volatility context.
Shared by
Alex
Licence
MIT
Version
1.0 (1 Dec 2026)
Settings
8 inputs
Lab check
Compiled with MetaEditor build 6333 for MT5 on 1 Dec 2026: 0 errors, 0 warnings.
Price
Free to download

Settings read from the code

InputTypeDefaultNote
InpMaPeriodint20Moving average period
InpMaMethodENUM_MA_METHODMODE_EMAMoving average type (SMA, EMA, SMMA, LWMA)
InpPriceENUM_APPLIED_PRICEPRICE_CLOSEPrice used for the moving average
InpAtrPeriodint14ATR period (Wilder smoothing)
InpMultiplierdouble2.0Band distance in ATRs
InpBandColorcolorclrSteelBlueColour of the upper and lower bands
InpMiddleColorcolorclrGoldenrodColour of the middle line
InpShowMiddlebooltrueShow the middle line

How to use it

  1. Download the compiled file (or the source and compile it in MetaEditor).
  2. Put it in MetaTrader: File → Open Data Folder → MQL5 → Indicators, then refresh the Navigator.
  3. Test it on a demo account before any real money.
  4. Want changes? Open a copy in your Lab and ask for them in plain words.