Calculate the Vortex Indicator for a given price series.

The Vortex Indicator quantifies the presence and strength of a directional trend by comparing each period’s price movement away from the prior period’s range to the period’s overall volatility (True Range). It consists of two lines, VI+ and VI-, whose crossovers signal potential trend changes: VI+ above VI- suggests an uptrend is in control, VI- above VI+ suggests a downtrend is in control.

The formula is as follows:

\[\text{VM} + = | \operatorname{High}(t) - \operatorname{Low}(t-1) |\] \[\text{VM} - = | \operatorname{Low}(t) - \operatorname{High}(t-1) |\] \[\text{VI} + = \operatorname{Sum}(\text{VM} +,\; \text{window}) / \operatorname{Sum}(\text{True Range},\; \text{window})\] \[\text{VI} - = \operatorname{Sum}(\text{VM} -,\; \text{window}) / \operatorname{Sum}(\text{True Range},\; \text{window})\]

Also known as: VI, Vortex Indicator +/-, trend direction indicator.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Vortex Indicator for you. Just ask in plain English.

Calculate the Vortex Indicator in Python

The Vortex Indicator is available in the Technicals module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_vortex_indicator as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(tickers=["AAPL", "MSFT"])

toolkit.technicals.get_vortex_indicator().xs("AAPL", level=1, axis="columns")

Which returns:

Date VI+ VI-
2022-12-16 0.7841 1.0588
2022-12-19 0.7914 1.0685
2022-12-20 0.7615 1.1866
2022-12-21 0.6978 1.1025
2022-12-22 0.6841 1.1164
2022-12-23 0.6603 1.1994
2022-12-27 0.693 1.1657
2022-12-28 0.687 1.105
2022-12-29 0.6859 1.0921
2022-12-30 0.6736 1.1363

Parameters

get_vortex_indicator accepts the following parameters:

  • period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
  • close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
  • window (int, optional): The number of periods to sum the directional movement and true range over. Defaults to 14.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the VI+ and VI- values. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.

The Technicals module page introduces the module, and the sidebar lists all of its functions.

Share