Bentrix Docs
HomePricingDashboard

Vortex Indicator

Trend strengthoscillator2 linesin every package

Two lines: the upward movement (each high against the previous low) and the downward movement (each low against the previous high), each summed over the period and divided by the summed true range.

Where the two cross, the direction of movement has changed. It measures the strength of the upward and the downward movement.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
1
bar —O — H — L — C —main line —signal —first value at —
Show where:

Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.

What this figure shows

The figure is computed over 300 sample bars. Vortex has no value on the first 14 — the bars it needs before it can answer — and its first value stands on bar 15. Its line runs between 0.6031 and 1.43 on these bars, and the last value is 1.17. Counting the conditions the study declares on these bars: crosses above 1 6 times; crosses below 1 6 times; the first line crosses above the second 6 times; the first line crosses below the second 6 times. Press a condition under the figure to see each place marked. As states rather than moments: is above 1 on 145 bars; is below 1 on 141 bars.

02Its parts, named

The bars it readseach bar's open, high, low and closeWarm-upno value on the first 14 bars: thestudy needs them before it cananswerThe main linethe study's own value on each barLevel 1a fixed reference the study is readagainstThe second linedrawn with the main line: its signalor its partner
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

Two lines in their own pane, VI+ and VI−, usually between about 0.5 and 1.5. VI+ above VI− means the bars have recently reached further up than down; the reverse means further down.

04Where it comes from

Etienne Botes and Douglas Siepman introduced the Vortex Indicator in 2010, inspired by Viktor Schauberger's observations of vortices in flowing water. The idea is close to Wilder's directional movement: compare how far each bar's high reaches above the previous low with how far its low reaches below the previous high.

05The formula

Over N bars (14 by default), the upward and downward reaches, each divided by the sum of true ranges:

VMt+=|Ht−Lt−1|,VMt−=|Lt−Ht−1|
VI+=∑NVM+∑NTR,VI−=∑NVM−∑NTR
Ht, Ltthis bar's high and low; t−1, the bar before
VM+, VM−the upward and the downward reach
TReach bar's true range
Nthe period — 14 by default

06A worked example

The sample bars used here are eight: closes 20, 21, 23, 22, 24, 25, 24, 26; highs 21, 22, 24, 24, 25, 26, 26, 27; lows 18, 19, 20, 21, 21, 23, 23, 23; opens 19, 20, 21, 23, 22, 24, 25, 24.

Take a period of 3 and the last three bars. The upward vortex movement of a bar is the distance from its high to the previous bar's low; the downward one from its low to the previous bar's high.

  • upward: |26 − 21|, |26 − 23|, |27 − 23| = 5, 3, 4, sum 12
  • downward: |23 − 25|, |23 − 26|, |23 − 26| = 2, 3, 3, sum 8
  • true ranges: 3, 3, 4, sum 10

VI+ = 12 / 10 = 1.20 and VI− = 8 / 10 = 0.80

07Built in Assay

The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.

THE SCRIPT’S GRAPH
//@version=6
indicator("Vortex Indicator")
length = input.int(14, "Length")
// Upward movement: from the last bar's low to this bar's high; downward: from the last high to this low.
upMove = math.abs(high - low[1])
downMove = math.abs(low - high[1])
trueRange = math.max(high - low, math.abs(close[1] - high), math.abs(close[1] - low))
// Each movement summed over the window, as a share of the true range summed alike.
totalUp = math.sum(upMove, length)
totalDown = math.sum(downMove, length)
totalRange = math.sum(trueRange, length)
plusVi = na(totalRange) ? na : totalRange > 0 ? totalUp / totalRange : 0.0
minusVi = na(totalRange) ? na : totalRange > 0 ? totalDown / totalRange : 0.0
plot(plusVi, "+VI")
plot(minusVi, "-VI")

Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.

08Readings — what traders look for

The crossing. VI+ crossing above VI− is read as upward reach overtaking downward reach; the reverse crossing, the opposite.

The gap. A wide gap between the lines is read as one-sided movement; lines that cross repeatedly as a market without direction.

How the crossing fails. The two lines cross when the downward reach of recent bars overtakes the upward one. In a range each side takes the lead for a few bars at a time.

09In different markets and timeframes

The Vortex Indicator separates quickly at the start of a directional move and crosses often in ranges. It uses highs, lows and the true range, so gaps count.

In a sustained trend one line stays above the other for weeks of daily bars and the gap between them widens while the move extends each bar's high or low beyond the previous bar's. In a range the lines stay close to 1 and cross every few bars. With 14 bars on M5 it covers about an hour and crosses many times a day. Because it is built on the true range, a gap moves both lines on the bar it happens.

10With other studies

Read as a pair (VI+ against VI−) and beside the directional lines of Wilder's system, of which it is a simpler relative; the ADX can serve as its strength filter.

11What it does not tell you

!

It compares reaches over the last N bars. A crossing describes those bars; in a range the lines cross often, each crossing as clear as the last.

12Inputs and defaults

Vortex (14, Chart)settings card
1Time Period14
2TimeframeChart
3Wait for the candle to closeOn
  1. 1
    Time Period — 14Number of bars in the rolling sums
  2. 2
    Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
  3. 3
    Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.

What each input changes

  • Time PeriodThe number of bars looked back over. Longer: steadier and later. Shorter: quicker and noisier.
  • In use14 by default; 21 to 30 to reduce crossings.

13Limits and common misreadings

No threshold of strength is part of the design; unlike ADX, it has no single line for how strong a move is.

Gaps count fully in the reaches, so one gap can lift a line for N bars.

14Conditions an alert or a strategy can watch

crosses above 1 eventcrosses below 1 eventis above 1 stateis below 1 statethe first line crosses above the second eventthe first line crosses below the second event

Event: the bar it happens on an event happens on one barState: every bar while it holds a state holds on every bar while it lasts

These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.

15Practise it in the laboratory

Attach Vortex and ADX together on an H1 replay. Count the Vortex crossings in a range-bound day and see what ADX read on each.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Trend strength › Vortex, or type Vortex in its search.
  • Its settings: the settings card opens when it is added; its legend's name opens it again.

18From an agent or a program

Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "vortex"}).

The study, as a chart files it

This is a new Vortex’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.

{
  "applied": "close",
  "convention": "talib",
  "kind": "vortex",
  "settings": {
    "shape": "ta",
    "values": {
      "optInTimePeriod": 14.0
    }
  }
}

An agent

An agent calls the MCP tool with it:

{
  "name": "study_values",
  "arguments": {
    "bench": "bentrix://lab/\u2026/bench/\u2026",
    "symbol": "EURUSD",
    "timeframe": "H1",
    "limit": 5,
    "study": {
      "applied": "close",
      "convention": "talib",
      "kind": "vortex",
      "settings": {
        "shape": "ta",
        "values": {
          "optInTimePeriod": 14.0
        }
      }
    }
  }
}

A program

A program does the same in its language — bench and market as in the built-in indicators guide:

Python

values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "talib", "kind": "vortex", "settings": {"shape": "ta", "values": {"optInTimePeriod": 14.0}}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
    print("line:", line["line"])
    print("  newest values:", line["values"])

JSJavaScript

const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "talib", "kind": "vortex", "settings": { "shape": "ta", "values": { "optInTimePeriod": 14.0 } } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
  console.log("line:", line.line);
  console.log("  newest values:", line.values);
}

C#C#

var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "talib", ["kind"] = "vortex", ["settings"] = new Dictionary<string, object?> { ["shape"] = "ta", ["values"] = new Dictionary<string, object?> { ["optInTimePeriod"] = 14.0 } } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
    Console.WriteLine($"line: {line!["line"]!}");
    Console.WriteLine($"  newest values: {line!["values"]!}");
}

GOGo

values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "talib", "kind": "vortex", "settings": map[string]any{"shape": "ta", "values": map[string]any{"optInTimePeriod": 14.0}}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
	fmt.Println("line:", at(line, "line"))
	fmt.Println("  newest values:", at(line, "values"))
}

Java

Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "talib", "kind", "vortex", "settings", obj("shape", "ta", "values", obj("optInTimePeriod", 14.0)))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
    System.out.println("line:" + " " + at(line, "line"));
    System.out.println("  newest values:" + " " + at(line, "values"));
}

C++C++

auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "talib"}, {"kind", "vortex"}, {"settings", Json::Object{{"shape", "ta"}, {"values", Json::Object{{"optInTimePeriod", 14.0}}}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
    std::cout << "line:" << " " << line["line"].dump() << std::endl;
    std::cout << "  newest values:" << " " << line["values"].dump() << std::endl;
}

Julia

values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "talib", "kind" => "vortex", "settings" => Dict{String,Any}("shape" => "ta", "values" => Dict{String,Any}("optInTimePeriod" => 14.0))); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
    println("line:", " ", line["line"])
    println("  newest values:", " ", line["values"])
end

RR

values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "talib", kind = "vortex", settings = list(shape = "ta", values = list(optInTimePeriod = 14.0))), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
  cat("line:", format(line$line), "\n")
  cat("  newest values:", format(line$values), "\n")
}

RRust

let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "talib", "kind": "vortex", "settings": {"shape": "ta", "values": {"optInTimePeriod": 14.0}}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
    println!("line: {}", line["line"]);
    println!("  newest values: {}", line["values"]);
}

Reading the answer

  • times — the candles’ open times, in milliseconds since 1970 (UTC), oldest first.
  • lines — one entry per line, in this order, each with its line name and its values; values[i] belongs to the candle at times[i].
  • The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
  • null is a candle with no value yet — the warm-up, about 1 × the period at the start of the history.
  • Its fixed levels, drawn on the chart: [1.0].
lineWhat it is
Mainthe indicator's own value
Signala smoothing of the main line, drawn beside it

In a strategy

Filed under a key of your choice in a strategy document’s studies — here vortex: {"vortex": {"applied": "close", "convention": "talib", "kind": "vortex", "settings": {"shape": "ta", "values": {"optInTimePeriod": 14.0}}}} — its rules can name:

WriteWhat it is
vortexits main line, as a value in a compare
vortex.signalthis line, as a value in a compare
{"cond": "vortex:level.cross_up:1"}a condition it declares itself
{"cond": "vortex:level.cross_down:1"}a condition it declares itself
{"cond": "vortex:level.above:1"}a condition it declares itself
{"cond": "vortex:level.below:1"}a condition it declares itself
{"cond": "vortex:lines.cross_up"}a condition it declares itself
{"cond": "vortex:lines.cross_down"}a condition it declares itself

19Sources

  1. Botes, Etienne & Siepman, Douglas. "The Vortex Indicator." Technical Analysis of Stocks & Commodities, January 2010.

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed