DV Intermediate Oscillator (DVI)

Calculate David Varadi’s DV Intermediate Oscillator (DVI), from 0 to 1, which shows how stretched the price is.

It blends rankings of how far the price stands from its short average and of the balance of up and down days.

The DVI is a smooth oscillator between 0 and 1 that combines two rankings over the last window periods. The magnitude ranks how far the price stands above or below its 3-period average, smoothed over a short and a long window; the stretch ranks the number of up days against down days over a short and a long window. Varadi weights the magnitude 0.8 and the stretch 0.2.

The formula is as follows:

\[\text{Return} = \frac{\operatorname{Close}(t)}{\operatorname{SMA}(\text{Close},\; 3)} - 1\] \[\text{Magnitude} = \operatorname{SMA}\left(\frac{\operatorname{SMA}(\text{Return},\; 5) + \frac{\operatorname{SMA}(\text{Return},\; 100)}{10}}{2},\; 5\right)\] \[\text{Direction} = + 1 \;\text{if Close}(t) > \operatorname{Close}(t - 1),\;\; \text{else -1}\] \[\text{Stretch} = \operatorname{SMA}\left(\frac{\operatorname{Sum}(\text{Direction},\; 10) + \frac{\operatorname{Sum}(\text{Direction},\; 100)}{10}}{2},\; 2\right)\] \[\text{DVI Magnitude} = \text{Percent Rank}(\text{Magnitude},\; \text{window})\] \[\text{DVI Stretch} = \text{Percent Rank}(\text{Stretch},\; \text{window})\] \[\text{DVI} = \text{magnitude\_weight} \cdot \text{DVI Magnitude} + (1 - \text{magnitude\_weight}) \cdot \text{DVI Stretch}\]

The Percent Rank is the share of the previous window values that are lower than the latest one, as in get_percent_rank. A DVI above 0.5 marks a price stretched upwards relative to the past year and one below 0.5 a price stretched downwards. Varadi uses it for short-term mean reversion: buy below 0.5 and sell above it, preferably in the direction of the longer trend.

Also known as: DVI, DV Intermediate, DV indicator.

Example · AAPL, MSFT · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_dv_intermediate_oscillator:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

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

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

Was Apple overbought or oversold in 2025 according to the DV Intermediate Oscillator?

Which returns:

Parameters

get_dv_intermediate_oscillator accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
windowintThe number of previous periods of the Percent Ranks. Defaults to 252, a year of trading days.20
magnitude_weightfloatThe weight of the magnitude in the DVI, between 0 and 1; the stretch gets the rest. Defaults to 0.8, Varadi’s own.
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the indicator values. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

Share