Appearance
Moving Average Channel
SMA of the highs and SMA of the lows as a channel.
Kind indicator · Drawn on the price pane
Try it
On the chart, press / and choose Moving Average Channel under Bands & channels. To change it, copy the source below into the AlphaScript editor.
Inputs
| Input | Type | Default |
|---|---|---|
| Upper length | int | 20 |
| Lower length | int | 20 |
| Upper offset | int | 0 |
| Lower offset | int | 0 |
| Upper color | color | "#2962FF" |
| Lower color | color | "#FF6D00" |
| Background | color | "rgba(33,150,243,0.05)" |
Source
From packages/alphascript/indicators/machannel.as.js.
js
indicator({ name: "Moving Average Channel", shortTitle: "MAC", overlay: true });
const upperLength = input.int("Upper length", 20, { min: 1 }), lowerLength = input.int("Lower length", 20, { min: 1 });
const upperOffset = input.int("Upper offset", 0, { min: -500, max: 500 }), lowerOffset = input.int("Lower offset", 0, { min: -500, max: 500 });
const upper = ta.sma(candle.high, upperLength), lower = ta.sma(candle.low, lowerLength);
plot(upper, { title: "Upper", offset: upperOffset, color: input.color("Upper color", "#2962FF", { group: "Style" }) });
plot(lower, { title: "Lower", offset: lowerOffset, color: input.color("Lower color", "#FF6D00", { group: "Style" }) });
fill(upper, lower, { title: "Background", color: input.color("Background", "rgba(33,150,243,0.05)", { group: "Style" }) });