Variable Index Dynamic Average

The Variable Index Dynamic Average (VIDYA) of Tushar Chande (1992) is an EMA whose smoothing factor grows with the strength of the price move, measured by the absolute Chande Momentum Oscillator.

The formula for the Variable Index Dynamic Average starts from the sums of the gains and of the losses of the close from period to period over the last m periods, which give the absolute Chande Momentum Oscillator CMO, between 0 and 1:

\[\text{Gains} = \sum_{i=0}^{m - 1} \max\left(\text{Close}_{t-i} - \text{Close}_{t-i-1}, 0\right)\] \[\text{Losses} = \sum_{i=0}^{m - 1} \max\left(\text{Close}_{t-i-1} - \text{Close}_{t-i}, 0\right)\] \[\text{Absolute CMO} = \frac{\left\lvert \text{Gains} - \text{Losses}\right\rvert}{\text{Gains} + \text{Losses}}\]

The VIDYA is an EMA of n periods whose smoothing factor alpha is scaled by that oscillator:

\[\alpha = \frac{2}{n + 1}\] \[\text{VIDYA} = \alpha \cdot \text{Absolute CMO} \cdot \text{Close} + (1 - \alpha \cdot \text{Absolute CMO}) \cdot \text{VIDYA}_{t-1}\]

Where \(\text{Close}_{t - i}\) is the close i periods ago and VIDYA(t-1) the average of the period before. In a strong trend, where the price moves mostly one way, the CMO is close to 1 and the VIDYA follows the price like an EMA; in a sideways market the CMO is close to 0 and the VIDYA barely moves.

A moving average smooths the price by averaging it over the last n periods, so that the trend shows through the noise of single periods. It is the oldest and most widely used trend indicator: the direction of the average shows the direction of the trend, the price above (below) it an uptrend (downtrend), and other indicators, from the MACD to the Bollinger Bands, are built on it. Every moving average trades smoothness against lag: the more periods it averages, the smoother it is and the later it turns after the price. The averages differ in how they weight the prices within the window and whether they adapt their speed to the market, each a different answer to that trade-off.

Also known as: VIDYA, Chande’s dynamic average, variable moving average.

In the Finance Toolkit this is get_moving_average with method="variable_index_dynamic", the same function as Moving Average.

Example · ^GSPC · 2021 to 2025

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

from financetoolkit import Toolkit

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

toolkit.technicals.get_moving_average(method="variable_index_dynamic", window=50)

Which returns:

References

  • Paper Chande, T.S. (1992). “Adapting Moving Averages to Market Volatility.” Technical Analysis of Stocks & Commodities, 10(3).
  • Paper Chande, T.S. & Kroll, S. (1994). “The New Technical Trader.” Wiley.
  • Library Referenced against TA-Lib’s VIDYA (Variable Index Dynamic Average)
  • Library Referenced against pandas-ta-classic’s vidya (Variable Index Dynamic Average)
Share