Skip to content

Moving Average Ribbon ​

Four moving averages of one type, 20 to 200 bars.

Kind indicator · Drawn on the price pane

Try it ​

On the chart, press / and choose Moving Average Ribbon under Moving averages. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
MA typeselect"SMA"
Sourcesource"close"
MA #1 lengthint20
MA #2 lengthint50
MA #3 lengthint100
MA #4 lengthint200
MA #1 colorcolor"#F6C309"
MA #2 colorcolor"#FB9800"
MA #3 colorcolor"#FB6500"
MA #4 colorcolor"#F60C0C"

Source ​

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

js
indicator({ name: "Moving Average Ribbon", shortTitle: "MA Ribbon", overlay: true });
const maType = input.select("MA type", "SMA", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"]);
const src = input.source("Source", "close");
const l1 = input.int("MA #1 length", 20, { min: 1 }), l2 = input.int("MA #2 length", 50, { min: 1 });
const l3 = input.int("MA #3 length", 100, { min: 1 }), l4 = input.int("MA #4 length", 200, { min: 1 });
/** @param {Series} s @param {number} n */
const ma = (s, n) => maType === "EMA" ? ta.ema(s, n) : maType === "SMMA (RMA)" ? ta.rma(s, n) : maType === "WMA" ? ta.wma(s, n) : maType === "VWMA" ? ta.vwma(s, n) : ta.sma(s, n);
plot(ma(src, l1), { title: "MA #1", color: input.color("MA #1 color", "#F6C309", { group: "Style" }) });
plot(ma(src, l2), { title: "MA #2", color: input.color("MA #2 color", "#FB9800", { group: "Style" }) });
plot(ma(src, l3), { title: "MA #3", color: input.color("MA #3 color", "#FB6500", { group: "Style" }) });
plot(ma(src, l4), { title: "MA #4", color: input.color("MA #4 color", "#F60C0C", { group: "Style" }) });

AlphaScript language v0.1 · runtime 0.2.0