Skip to content

Supertrend ​

ATR trailing line that flips with the trend.

Kind indicator · Drawn on the price pane

Try it ​

On the chart, press / and choose Supertrend under Trend. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
ATR lengthint10
Factorfloat3
Up colorcolor"#089981"
Down colorcolor"#F23645"

Source ​

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

js
indicator({ name: "Supertrend", shortTitle: "Supertrend", overlay: true });
const atrLength = input.int("ATR length", 10, { min: 1 });
const factor = input.float("Factor", 3, { min: 0.01, step: 0.01 });
const st = ta.supertrend(factor, atrLength);
plot(ta.calc([st.line, st.direction], (l, d) => (d < 0 ? l : NaN)), { title: "Up trend", width: 2, color: input.color("Up color", "#089981", { group: "Style" }) });
plot(ta.calc([st.line, st.direction], (l, d) => (d > 0 ? l : NaN)), { title: "Down trend", width: 2, color: input.color("Down color", "#F23645", { group: "Style" }) });

AlphaScript language v0.1 · runtime 0.2.0