Keltner Channels
An exponential moving average with bands a multiple of the Average True Range above and below it.
- KC
- Built into Spectral
- Updates every tick
- keltner channels
- channel
- atr
- ema
- bands
- squeeze
- volatility
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
Keltner Channels draw a moving average of price (the basis) with an upper and a lower band at a multiple of the Average True Range (ATR) above and below it. Because ATR measures the typical bar size including gaps, the channel widens in volatile markets and narrows in quiet ones.
With the defaults, the basis is the 20-bar exponential moving average of the close and the bands sit two 10-bar ATRs away, as on TradingView.
How to read it
In a trend, price tends to hold one side of the basis: pullbacks to the basis are common entries, and a close outside a band shows unusual strength or weakness. In a range, the bands mark where moves tend to stall.
Keltner Channels are smoother than Bollinger Bands, because ATR reacts less to a single large close than a standard deviation. When the Bollinger Bands contract inside the Keltner Channels, volatility is unusually low: the squeeze many traders watch (the Keltner 1.5 preset is the common setting for it).
Settings and limitations
Length sets the basis average; Multiplier the band distance (2 is standard, 1.5 for squeeze setups, 1 for tight channels). Bands chooses the range the multiplier scales: Average True Range over ATR length bars (standard), the current bar's true range (very jumpy), or the high-to-low range smoothed over Length bars. The classic preset approximates Chester Keltner's 1960 version: a 10-bar simple average of the typical price with bands one average range away.
The bands appear once the basis and the range both have values: after ATR length bars by default.
Notes
Matches TradingView's Keltner Channels, including its three band styles; the Range style uses Wilder smoothing of high minus low, as TradingView does, where Keltner used a simple average. The exponential basis starts at the first bar, while TradingView starts it after Length bars, so the bands appear earlier here and their first few dozen values can differ; later values match.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Length | Whole number | 20 | 1 – 500 | Bars in the moving average of the basis (and of the range when Bands use Range). |
| Basis average | Choice | EMA | EMA, SMA | Moving average of the basis. The modern definition uses an EMA; Chester Keltner's original used a simple average. |
| Source | Price source | close | open, high, low, close, hlc3 | Price the basis is computed from. |
| Multiplier | Number | 2 | 0.1 – 10, step 0.1 | Distance of each band from the basis, as a multiple of the band range (the ATR by default). |
| Bands | Choice | Average True Range | Average True Range, True Range, Range | What the multiplier scales: the Average True Range, the current bar's true range, or a smoothed high-to-low range over Length bars. |
| ATR length | Whole number | 10 | 1 – 500 | Bars in the Average True Range (Wilder smoothing) when Bands use Average True Range. |
Presets
Each preset is its own entry in the Indicators toolbox, with these settings changed.
| Toolbox entry | Short name | Settings |
|---|---|---|
| Keltner Channels (20, 1.5 ATR) | KC 1.5 | Multiplier: 1.5 |
| Keltner Channels (classic) | KC classic | Length: 10Basis average: SMASource: hlc3Bands: RangeMultiplier: 1 |
What it draws
Lines
- Basissolid · 1.5 px · primary
#C4A46A - Upper bandsolid · 1 px
#7FB5A0 - Lower bandsolid · 1 px
#7FB5A0
Zones
- Channel fillfilled at 7% opacity
#7FB5A0
Source
Save it as keltner-channels.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'keltner-channels',
name: 'Keltner Channels',
shortName: 'KC',
version: '1.0.0',
author: 'Spectral',
description: 'An exponential moving average with bands a multiple of the Average True Range above and below it.',
pane: 'price',
live: { lookback: 1 },
inputs: {
length: { type: 'integer', label: 'Length', default: 20, min: 1, max: 500, description: 'Bars in the moving average of the basis (and of the range when Bands use Range).' },
maType: { type: 'select', label: 'Basis average', default: 'EMA', options: ['EMA', 'SMA'], description: 'Moving average of the basis. The modern definition uses an EMA; Chester Keltner\'s original used a simple average.' },
source: { type: 'source', label: 'Source', default: 'close', description: 'Price the basis is computed from.' },
mult: { type: 'number', label: 'Multiplier', default: 2, min: 0.1, max: 10, step: 0.1, description: 'Distance of each band from the basis, as a multiple of the band range (the ATR by default).' },
bandsStyle: { type: 'select', label: 'Bands', default: 'Average True Range', options: ['Average True Range', 'True Range', 'Range'], description: 'What the multiplier scales: the Average True Range, the current bar\'s true range, or a smoothed high-to-low range over Length bars.' },
atrLength: { type: 'integer', label: 'ATR length', default: 10, min: 1, max: 500, description: 'Bars in the Average True Range (Wilder smoothing) when Bands use Average True Range.' },
},
plots: {
basis: { label: 'Basis', color: '#C4A46A', lineWidth: 1.5, primary: true },
upper: { label: 'Upper band', color: '#7FB5A0', lineWidth: 1 },
lower: { label: 'Lower band', color: '#7FB5A0', lineWidth: 1 },
},
zones: {
band: { label: 'Channel fill', color: '#7FB5A0', opacity: 0.07 },
},
presets: [
{ id: 'squeeze', name: 'Keltner Channels (20, 1.5 ATR)', shortName: 'KC 1.5', inputs: { mult: 1.5 } },
{ id: 'classic', name: 'Keltner Channels (classic)', shortName: 'KC classic', inputs: { length: 10, maType: 'SMA', source: 'hlc3', bandsStyle: 'Range', mult: 1 } },
],
docs: {
overview: 'Keltner Channels draw a moving average of price (the basis) with an upper and a lower band at a multiple of the Average True Range (ATR) above and below it. Because ATR measures the typical bar size including gaps, the channel widens in volatile markets and narrows in quiet ones.\n\nWith the defaults, the basis is the 20-bar exponential moving average of the close and the bands sit two 10-bar ATRs away, as on TradingView.',
howToRead: 'In a trend, price tends to hold one side of the basis: pullbacks to the basis are common entries, and a close outside a band shows unusual strength or weakness. In a range, the bands mark where moves tend to stall.\n\nKeltner Channels are smoother than Bollinger Bands, because ATR reacts less to a single large close than a standard deviation. When the Bollinger Bands contract inside the Keltner Channels, volatility is unusually low: the squeeze many traders watch (the Keltner 1.5 preset is the common setting for it).',
settings: 'Length sets the basis average; Multiplier the band distance (2 is standard, 1.5 for squeeze setups, 1 for tight channels). Bands chooses the range the multiplier scales: Average True Range over ATR length bars (standard), the current bar\'s true range (very jumpy), or the high-to-low range smoothed over Length bars. The classic preset approximates Chester Keltner\'s 1960 version: a 10-bar simple average of the typical price with bands one average range away.\n\nThe bands appear once the basis and the range both have values: after ATR length bars by default.',
notes: 'Matches TradingView\'s Keltner Channels, including its three band styles; the Range style uses Wilder smoothing of high minus low, as TradingView does, where Keltner used a simple average. The exponential basis starts at the first bar, while TradingView starts it after Length bars, so the bands appear earlier here and their first few dozen values can differ; later values match.',
},
calculate(ctx) {
const { bars, inputs, ta } = ctx;
const source = ta.source(bars, inputs.source);
const basis = inputs.maType === 'SMA' ? ta.sma(source, inputs.length) : ta.ema(source, inputs.length);
let range;
if (inputs.bandsStyle === 'True Range') range = ta.trueRange(bars);
else if (inputs.bandsStyle === 'Range') range = ta.rma(bars.map((bar) => bar.high - bar.low), inputs.length);
else range = ta.atr(bars, inputs.atrLength);
const upper = basis.map((value, index) => (value === null || range[index] === null ? null : value + inputs.mult * range[index]));
const lower = basis.map((value, index) => (value === null || range[index] === null ? null : value - inputs.mult * range[index]));
return { plots: { basis, upper, lower }, zones: { band: { upper, lower } } };
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/keltner-channels.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


