Bentrix Docs
HomePricingDashboard

Keltner Channels

Trend & channelsoverlay3 linesin every package

An exponential moving average of the price with an upper and a lower line a multiple of the average true range above and below it.

It measures distance from the centre in units of the market's own recent bar movement, where Bollinger Bands measure it in standard deviations. The average true range is Wilder's; with Band set to Range it is Keltner's original form, the average of each bar's high minus its low. Read as a volatility-scaled envelope: the channel's width, and price against its edges.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
bar —O — H — L — C —middle band —band —band —first value at —
Show where:

Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.

What this figure shows

The figure is computed over 300 sample bars. Keltner Channels has no value on the first 19 — the bars it needs before it can answer — and its first value stands on bar 20. Counting the conditions the study declares on these bars: price crosses above the upper band 7 times; price crosses below the lower band 12 times; price comes back inside the bands 20 times; price crosses above the middle line 5 times; price crosses below the middle line 5 times. Press a condition under the figure to see each place marked.

02Its parts, named

Warm-upno value on the first 19 bars: thestudy needs them before it cananswerThe upper banda set distance above the middleThe lower bandthe same distance below the middleThe middlean average of price: the band'scentreThe bars it readseach bar's close, unless you chooseanother price
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

An exponential average with a band above and below at a multiple of the average true range. Smoother than Bollinger Bands, because the ATR changes more slowly than the standard deviation.

04Where it comes from

Named after Chester W. Keltner, who described a channel around a ten-day average in 1960. The modern form, with an EMA and a multiple of the ATR, became the common one in the 1980s and 1990s.

05The formula

Mid=EMA(P,N),Upper/Lower=Mid±m·ATR(Natr)
Pthe applied price — the close by default
N, Natrthe EMA's period and the ATR's
mthe multiple of the ATR

Bentrix's settings: the EMA's period, the ATR's period, the multiple m, and whether the range is Wilder's true range or the bar's own high minus low.

06A worked example

Take an average of the typical price that reads 24.60, an ATR of 3.50, and a multiplier of 2.

  • upper = 24.60 + 2 × 3.50 = 31.60
  • lower = 24.60 − 2 × 3.50 = 17.60

Those round figures are close to what real bars give. Take eight with highs 21, 22, 24, 24, 25, 26, 26, 27, lows 18, 19, 20, 21, 21, 23, 23, 23 and closes 20, 21, 23, 22, 24, 25, 24, 26, a period of 3 for both the average and the ATR, and a multiplier of 2. On the last bar the average of the typical price reads 24.653 and the ATR 3.498: the upper line is 24.653 + 2 × 3.498 = 31.65 and the lower 24.653 − 2 × 3.498 = 17.66.

Compare with Bollinger Bands on the same bars: their width comes from the standard deviation of closes, which leaps when one unusual close enters the window. The ATR here is a smoothed average of bar ranges and changes slowly, so Keltner Channels widen and narrow far more gradually. The Squeeze studies are built on exactly that difference — Bollinger Bands moving inside Keltner Channels.

07Built in Assay

The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.

THE SCRIPT’S GRAPH
//@version=6
indicator("Keltner Channels", overlay = true)
length = input.int(20, "Length")
atrLength = input.int(10, "ATR period")
mult = input.float(2.0, "Multiplier")
// The middle line: an exponential average of the typical price.
middle = ta.ema(hlc3, length)
// The width: Wilder's average true range, started where the middle line starts, from the mean
// of the true ranges just before it.
trueRange = math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1]))
start = math.max(length - 1, atrLength)
seed = ta.sma(trueRange, atrLength)
var float atr = na
if bar_index == start
    atr := seed
else if bar_index > start
    atr := (atr * (atrLength - 1) + trueRange) / atrLength
plot(middle, "Middle")
plot(middle + mult * atr, "Upper")
plot(middle - mult * atr, "Lower")

Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.

08Readings — what traders look for

Closes outside the channel are read as a move larger than the market's ordinary range.

Bollinger inside Keltner. When Bollinger Bands narrow until they sit inside the Keltner Channel, traders call it a squeeze — the idea behind SQZMOM.

The middle line's slope is read as the trend.

How a close outside the channel fails. Linda Raschke's reading — the modern form of the channel is hers — takes a close outside as strength. In a strong trend price presses against one band bar after bar; a touch of the band is then the normal state of the trend, not its limit. And in a quiet market the channel is narrow enough that an ordinary bar closes outside it.

09In different markets and timeframes

Keltner Channels are an average with an ATR-wide band: smoother than Bollinger Bands and slower to react to a volatility shock. In trends price runs along or beyond one line.

In a range most bars stay between the two outer lines and cross the middle one back and forth. Because the width is an average of bar ranges, the channel is wide on markets and timeframes whose bars are long against their net movement — M1 charts, thin markets — and price then seldom reaches its lines; on daily bars of a trending market closes outside it come in runs. A gap enters the width only when the true range is used, which is what the True range input decides.

10With other studies

Read with Bollinger Bands of the same period — the bands inside the channel is the Squeeze — and beside the ATR.

11What it does not tell you

!

A close outside the channel describes a large move that has happened; it says nothing of the next one.

12Inputs and defaults

Keltner Channels (10, 2)settings card
1ATR period10
2Multiplier2
3Period20
4True rangeTrue
5Applied priceClose
6TimeframeChart
7Wait for the candle to closeOn
  1. 1
    ATR period — 10The window of the average true range that sets the width.
  2. 2
    Multiplier — 2How many ATRs each channel line stands from the middle.
  3. 3
    Period — 20The period of the middle line, an EMA of the typical price.
  4. 4
    True range — TrueWhether the width uses the true range (gaps included) or the plain high-minus-low range, as Keltner's original did.
  5. 5
    Applied price — CloseAny of the seven prices, and several at once, each its own line with its own look.
  6. 6
    Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
  7. 7
    Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.

The settings in use

  • In use20, 10 and 2 here; Raschke's version uses a 20-bar EMA and 2.5 ATRs.

13Limits and common misreadings

Several versions exist: Keltner's 1960 original (a 10-day average of the typical price and of the daily range) and the ATR form used today. Settings must match before two charts are compared.

The width lags a volatility shock by the ATR's smoothing.

14Conditions an alert or a strategy can watch

price crosses above the upper band eventprice crosses below the lower band eventprice comes back inside the bands eventprice crosses above the middle line eventprice crosses below the middle line event

Event: the bar it happens on an event happens on one barState: every bar while it holds a state holds on every bar while it lasts

These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.

15Practise it in the laboratory

Put Keltner Channels (20, 10, 2) and Bollinger Bands (20, 2) on one chart; find a stretch where the Bollinger Bands are entirely inside the channel and replay forward from it.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Trend & channels › Keltner Channels, or type Keltner Channels in its search.
  • Its settings: the settings card opens when it is added; its legend's name opens it again.

18From an agent or a program

Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "keltner"}).

The study, as a chart files it

This is a new Keltner Channels’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.

{
  "applied": "close",
  "convention": "custom",
  "kind": "keltner",
  "settings": {
    "atr_period": 10,
    "mult": 2.0,
    "period": 20,
    "shape": "keltner",
    "true_range": true
  }
}

An agent

An agent calls the MCP tool with it:

{
  "name": "study_values",
  "arguments": {
    "bench": "bentrix://lab/\u2026/bench/\u2026",
    "symbol": "EURUSD",
    "timeframe": "H1",
    "limit": 5,
    "study": {
      "applied": "close",
      "convention": "custom",
      "kind": "keltner",
      "settings": {
        "atr_period": 10,
        "mult": 2.0,
        "period": 20,
        "shape": "keltner",
        "true_range": true
      }
    }
  }
}

A program

A program does the same in its language — bench and market as in the built-in indicators guide:

Python

values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "custom", "kind": "keltner", "settings": {"atr_period": 10, "mult": 2.0, "period": 20, "shape": "keltner", "true_range": True}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
    print("line:", line["line"])
    print("  newest values:", line["values"])

JSJavaScript

const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "custom", "kind": "keltner", "settings": { "atr_period": 10, "mult": 2.0, "period": 20, "shape": "keltner", "true_range": true } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
  console.log("line:", line.line);
  console.log("  newest values:", line.values);
}

C#C#

var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "custom", ["kind"] = "keltner", ["settings"] = new Dictionary<string, object?> { ["atr_period"] = 10, ["mult"] = 2.0, ["period"] = 20, ["shape"] = "keltner", ["true_range"] = true } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
    Console.WriteLine($"line: {line!["line"]!}");
    Console.WriteLine($"  newest values: {line!["values"]!}");
}

GOGo

values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "custom", "kind": "keltner", "settings": map[string]any{"atr_period": 10, "mult": 2.0, "period": 20, "shape": "keltner", "true_range": true}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
	fmt.Println("line:", at(line, "line"))
	fmt.Println("  newest values:", at(line, "values"))
}

Java

Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "custom", "kind", "keltner", "settings", obj("atr_period", 10, "mult", 2.0, "period", 20, "shape", "keltner", "true_range", true))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
    System.out.println("line:" + " " + at(line, "line"));
    System.out.println("  newest values:" + " " + at(line, "values"));
}

C++C++

auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "custom"}, {"kind", "keltner"}, {"settings", Json::Object{{"atr_period", 10}, {"mult", 2.0}, {"period", 20}, {"shape", "keltner"}, {"true_range", true}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
    std::cout << "line:" << " " << line["line"].dump() << std::endl;
    std::cout << "  newest values:" << " " << line["values"].dump() << std::endl;
}

Julia

values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "custom", "kind" => "keltner", "settings" => Dict{String,Any}("atr_period" => 10, "mult" => 2.0, "period" => 20, "shape" => "keltner", "true_range" => true)); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
    println("line:", " ", line["line"])
    println("  newest values:", " ", line["values"])
end

RR

values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "custom", kind = "keltner", settings = list(atr_period = 10, mult = 2.0, period = 20, shape = "keltner", true_range = TRUE)), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
  cat("line:", format(line$line), "\n")
  cat("  newest values:", format(line$values), "\n")
}

RRust

let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "custom", "kind": "keltner", "settings": {"atr_period": 10, "mult": 2.0, "period": 20, "shape": "keltner", "true_range": true}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
    println!("line: {}", line["line"]);
    println!("  newest values: {}", line["values"]);
}

Reading the answer

  • times — the candles’ open times, in milliseconds since 1970 (UTC), oldest first.
  • lines — one entry per line, in this order, each with its line name and its values; values[i] belongs to the candle at times[i].
  • The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
  • null is a candle with no value yet — the warm-up, about 1 × the period at the start of the history.
lineWhat it is
BandMidmiddle band
BandEdgeband
BandEdgeband

In a strategy

Filed under a key of your choice in a strategy document’s studies — here keltner: {"keltner": {"applied": "close", "convention": "custom", "kind": "keltner", "settings": {"atr_period": 10, "mult": 2.0, "period": 20, "shape": "keltner", "true_range": true}}} — its rules can name:

WriteWhat it is
keltner.band_midthis line, as a value in a compare
{"cond": "keltner:band.cross_above_upper"}a condition it declares itself
{"cond": "keltner:band.cross_below_lower"}a condition it declares itself
{"cond": "keltner:band.back_inside"}a condition it declares itself
{"cond": "keltner:band.mid_cross_up"}a condition it declares itself
{"cond": "keltner:band.mid_cross_down"}a condition it declares itself

Its lines named band_edge are more than one line of that name, so a strategy reaches them through the conditions above rather than by name.

19Sources

  1. Colby, Robert W. The Encyclopedia of Technical Market Indicators, 2nd ed. McGraw-Hill, 2003, "Keltner Channel".
  2. Kirkpatrick, Charles D. & Dahlquist, Julie R. Technical Analysis: The Complete Resource for Financial Market Technicians, 2nd ed. FT Press, 2010.
  3. Keltner, Chester W. How to Make Money in Commodities. The Keltner Statistical Service, 1960.

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed