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 ATRandlower = 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
| Input | Default | What it does |
|---|---|---|
| MA period | 20 | Number of bars in the middle moving average. |
| MA type | EMA | SMA, EMA, SMMA or LWMA. |
| Applied price | Close | Price used for the average (close, open, high, low, median, typical, weighted). |
| ATR period | 14 | Number of bars in the ATR. |
| Multiplier | 2.0 | Band distance in ATRs. |
| Band colour | Steel blue | Colour of the upper and lower bands. |
| Middle colour | Goldenrod | Colour of the moving average. |
| Show middle | true | Shows or hides the middle line (its values stay available to iCustom). |
How to use it
- In MetaTrader choose File > Open Data Folder.
- MT4: copy
FXN_AtrBands.mq4intoMQL4/Indicators. MT5: copyFXN_AtrBands.mq5intoMQL5/Indicators. - 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.
- 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
| Input | Type | Default | Note |
|---|---|---|---|
| InpMaPeriod | int | 20 | Moving average period |
| InpMaMethod | ENUM_MA_METHOD | MODE_EMA | Moving average type (SMA, EMA, SMMA, LWMA) |
| InpPrice | ENUM_APPLIED_PRICE | PRICE_CLOSE | Price used for the moving average |
| InpAtrPeriod | int | 14 | ATR period (Wilder smoothing) |
| InpMultiplier | double | 2.0 | Band distance in ATRs |
| InpBandColor | color | clrSteelBlue | Colour of the upper and lower bands |
| InpMiddleColor | color | clrGoldenrod | Colour of the middle line |
| InpShowMiddle | bool | true | Show the middle line |
How to use it
- Download the compiled file (or the source and compile it in MetaEditor).
- Put it in MetaTrader: File → Open Data Folder → MQL5 → Indicators, then refresh the Navigator.
- Test it on a demo account before any real money.
- Want changes? Open a copy in your Lab and ask for them in plain words.