Skip to content

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 ​

InputTypeDefault
Upper lengthint20
Lower lengthint20
Upper offsetint0
Lower offsetint0
Upper colorcolor"#2962FF"
Lower colorcolor"#FF6D00"
Backgroundcolor"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" }) });

AlphaScript language v0.1 · runtime 0.2.0