Vortex Indicator
VI+ and VI-: upward and downward trend movement relative to the true range, for spotting trend starts and reversals.
- VI
- Built into Spectral
- Updates every tick
- vortex
- vi+ vi-
- trend reversal
- trend direction
- true range
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
The Vortex Indicator by Etienne Botes and Douglas Siepman measures trend movement between bars. Upward movement is the distance from the previous low to the current high, downward movement the distance from the previous high to the current low. Summed over Length bars and divided by the sum of the true range, they give VI+ and VI-.
How to read it
VI+ above VI- shows that upward movement dominates and an uptrend is in force; VI- above VI+ shows a downtrend. A cross of the two lines is the main signal: VI+ crossing above VI- can start an uptrend, the opposite cross a downtrend. The further apart the lines, the stronger the trend.
In sideways markets the lines cross often and stay close to 1.0, the dotted guide; confirm a cross with price breaking a recent high or low.
Settings and limitations
Length 14 is the common default (the authors also tested 21, available as a preset, and longer windows). Values appear after Length plus one bars. A longer length gives fewer, later crosses.
Notes
Matches TradingView's Vortex Indicator: the true range includes gaps from the previous close, and all three parts are plain sums over Length bars.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Length | Whole number | 14 | 2 – 500 | Number of bars summed for the vortex movements and the true range. |
Presets
Each preset is its own entry in the Indicators toolbox, with these settings changed.
| Toolbox entry | Short name | Settings |
|---|---|---|
| Vortex Indicator (21) | VI 21 | Length: 21 |
What it draws
Lines
- VI+solid · 1.5 px · primary
#3FB950 - VI-solid · 1.5 px
#E5534B
Levels
- 1.0dotted · 1 px
#788493
Source
Save it as vortex.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'vortex',
name: 'Vortex Indicator',
shortName: 'VI',
version: '1.0.0',
author: 'Spectral',
description: 'VI+ and VI-: upward and downward trend movement relative to the true range, for spotting trend starts and reversals.',
pane: 'oscillator',
live: { lookback: 'length' },
inputs: {
length: { type: 'integer', label: 'Length', default: 14, min: 2, max: 500, description: 'Number of bars summed for the vortex movements and the true range.' },
},
plots: {
plusVi: { label: 'VI+', color: '#3FB950', lineWidth: 1.5, primary: true },
minusVi: { label: 'VI-', color: '#E5534B', lineWidth: 1.5 },
},
levels: {
one: { label: '1.0', color: '#788493', lineStyle: 'dotted' },
},
presets: [
{ id: 'long', name: 'Vortex Indicator (21)', shortName: 'VI 21', inputs: { length: 21 } },
],
docs: {
overview: 'The Vortex Indicator by Etienne Botes and Douglas Siepman measures trend movement between bars. Upward movement is the distance from the previous low to the current high, downward movement the distance from the previous high to the current low. Summed over Length bars and divided by the sum of the true range, they give VI+ and VI-.',
howToRead: 'VI+ above VI- shows that upward movement dominates and an uptrend is in force; VI- above VI+ shows a downtrend. A cross of the two lines is the main signal: VI+ crossing above VI- can start an uptrend, the opposite cross a downtrend. The further apart the lines, the stronger the trend.\n\nIn sideways markets the lines cross often and stay close to 1.0, the dotted guide; confirm a cross with price breaking a recent high or low.',
settings: 'Length 14 is the common default (the authors also tested 21, available as a preset, and longer windows). Values appear after Length plus one bars. A longer length gives fewer, later crosses.',
notes: 'Matches TradingView\'s Vortex Indicator: the true range includes gaps from the previous close, and all three parts are plain sums over Length bars.',
},
calculate(ctx) {
const { bars, inputs, ta } = ctx;
const count = bars.length;
const upMove = new Array(count).fill(null);
const downMove = new Array(count).fill(null);
for (let index = 1; index < count; index += 1) {
upMove[index] = Math.abs(bars[index].high - bars[index - 1].low);
downMove[index] = Math.abs(bars[index].low - bars[index - 1].high);
}
const upSum = ta.sum(upMove, inputs.length);
const downSum = ta.sum(downMove, inputs.length);
const rangeSum = ta.sum(ta.trueRange(bars), inputs.length);
const ratio = (sum, index) => (sum[index] === null || !(rangeSum[index] > 0) ? null : sum[index] / rangeSum[index]);
return {
plots: {
plusVi: upSum.map((_, index) => ratio(upSum, index)),
minusVi: downSum.map((_, index) => ratio(downSum, index)),
},
levels: { one: 1 },
};
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/vortex.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


