Appearance
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
| Input | Type | Default |
|---|---|---|
| ATR length | int | 10 |
| Factor | float | 3 |
| Up color | color | "#089981" |
| Down color | color | "#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" }) });