Appearance
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
| Input | Type | Default |
|---|---|---|
| Length | int | 20 |
| Basis color | color | "#FF6D00" |
| Upper color | color | "#2962FF" |
| Lower color | color | "#2962FF" |
| Background | color | "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" }) });