Open-source scriptindicator/v1
Vortex Indicator
Compare positive and negative directional movement with rolling true range.
#oscillator#trend#vortex
Description
The Vortex Indicator sums upward and downward movement between consecutive highs and lows, then normalizes both by total true range. Crosses and separation between VI+ and VI- can help describe directional trend behavior.
Open-source script. Everyone can inspect the source code, use the script on a chart, and save an editable copy.
Release notes
Version history · 1 published version
Version 1CurrentChart updatedVortex Indicator · Aug 31, 2026
Source codempl-2.0View sourceHide source
indicator("Vortex Indicator", { overlay: false });
const length = input.int("Length", 14, { min: 2, max: 200 });
const ranges = tr();
const plusMove = high.map((v, i) => i === 0 ? NaN : Math.abs(v - low[i - 1]));
const minusMove = low.map((v, i) => i === 0 ? NaN : Math.abs(v - high[i - 1]));
const plus = close.map((_, i) => {
if (i < length) return NaN;
let numerator = 0;
let denominator = 0;
for (let j = i - length + 1; j <= i; j++) {
numerator += plusMove[j];
denominator += ranges[j];
}
return denominator === 0 ? 0 : numerator / denominator;
});
const minus = close.map((_, i) => {
if (i < length) return NaN;
let numerator = 0;
let denominator = 0;
for (let j = i - length + 1; j <= i; j++) {
numerator += minusMove[j];
denominator += ranges[j];
}
return denominator === 0 ? 0 : numerator / denominator;
});
plot(plus, { title: "VI+", color: "#26a69a", lineWidth: 2 });
plot(minus, { title: "VI-", color: "#ef5350", lineWidth: 2 });
Community discussion
0 comments
No comments yet. Start the discussion.