Appearance
Vortex Indicator
VI+ and VI- trend lines from upward and downward movement.
Kind indicator · Drawn in its own pane
Try it
On the chart, press / and choose Vortex Indicator under Trend. To change it, copy the source below into the AlphaScript editor.
Inputs
| Input | Type | Default |
|---|---|---|
| Length | int | 14 |
| VI + color | color | "#2962FF" |
| VI - color | color | "#E91E63" |
Source
From packages/alphascript/indicators/vortex.as.js.
js
indicator({ name: "Vortex Indicator", shortTitle: "VI", overlay: false, precision: 4 });
const period = input.int("Length", 14, { min: 2 });
const vmp = ta.sum(ta.calc([candle.high], (h) => math.abs(h - candle.low.at(1))), period);
const vmm = ta.sum(ta.calc([candle.low], (l) => math.abs(l - candle.high.at(1))), period);
const str = ta.sum(ta.atr(1), period);
plot(ta.calc([vmp, str], (v, s) => v / s), { title: "VI +", color: input.color("VI + color", "#2962FF", { group: "Style" }) });
plot(ta.calc([vmm, str], (v, s) => v / s), { title: "VI -", color: input.color("VI - color", "#E91E63", { group: "Style" }) });