Skip to content

Keltner Channels ​

EMA basis with ATR bands.

Kind indicator · Drawn on the price pane

Try it ​

On the chart, press / and choose Keltner Channels under Bands & channels. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
Lengthint20
Multiplierfloat2
Sourcesource"close"
ATR lengthint10
Upper colorcolor"#2962FF"
Basis colorcolor"#2962FF"
Lower colorcolor"#2962FF"
Backgroundcolor"rgba(33,150,243,0.05)"

Source ​

From packages/alphascript/indicators/keltner.as.js.

js
indicator({ name: "Keltner Channels", shortTitle: "KC", overlay: true });
const length = input.int("Length", 20, { min: 1 });
const mult = input.float("Multiplier", 2, { step: 0.1 });
const src = input.source("Source", "close");
const atrLength = input.int("ATR length", 10, { min: 1 });
const basis = ta.ema(src, length), range = ta.atr(atrLength);
const upper = ta.calc([basis, range], (b, r) => b + mult * r), lower = ta.calc([basis, range], (b, r) => b - mult * r);
plot(upper, { title: "Upper", color: input.color("Upper color", "#2962FF", { group: "Style" }) });
plot(basis, { title: "Basis", color: input.color("Basis color", "#2962FF", { group: "Style" }) });
plot(lower, { title: "Lower", color: input.color("Lower color", "#2962FF", { group: "Style" }) });
fill(upper, lower, { title: "Background", color: input.color("Background", "rgba(33,150,243,0.05)", { group: "Style" }) });

AlphaScript language v0.1 · runtime 0.2.0