Skip to content

Donchian Channels ​

Highest high and lowest low of N bars.

Kind indicator · Drawn on the price pane

Try it ​

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

Inputs ​

InputTypeDefault
Lengthint20
Basis colorcolor"#FF6D00"
Upper colorcolor"#2962FF"
Lower colorcolor"#2962FF"
Backgroundcolor"rgba(33,150,243,0.05)"

Source ​

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

js
indicator({ name: "Donchian Channels", shortTitle: "DC", overlay: true });
const length = input.int("Length", 20, { min: 1 });
const upper = ta.highest(candle.high, length), lower = ta.lowest(candle.low, length);
plot(ta.calc([upper, lower], (u, l) => (u + l) / 2), { title: "Basis", color: input.color("Basis color", "#FF6D00", { group: "Style" }) });
plot(upper, { title: "Upper", color: input.color("Upper 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