Back to Guides
Guide

Variable Index Dynamic Average (VIDyA) Formula

The variable index dynamic average formula, the scale trap in its CMO line, and why a VIDyA slows down or freezes instead of speeding up.

The variable index dynamic average is an exponential moving average whose smoothing factor is rescaled on every bar by how one-sided recent price changes have been. When up moves and down moves balance it barely moves; when they all run one way it behaves like the plain EMA underneath it.

The oscillator that drives it gets printed on two different scales, and using the wrong one breaks the calculation outright. And the common description, that the line speeds up in a trend, is the wrong way round: the arithmetic caps its speed at your own EMA setting.

VIDyA, VIDYA, Variable Index Dynamic Average and variable index dynamic moving average all name the same indicator. One open-source library also lists it as Chande's Variable Index Dynamic Average.

What is the variable index dynamic average?

An EMA with a variable smoothing factor, scaled each bar by the absolute value of the Chande Momentum Oscillator. MetaTrader's help page credits Tushar Chande with it and calls it "an original method of calculating the Exponential Moving Average (EMA) with the dynamically changing period of averaging", where the "Period of averaging depends on the market volatility; as the measure of volatility Chande Momentum Oscillator (CMO) was chosen". The specification in the open-source TA-Lib library says the line "follows the price like an EMA in a one-way move and stops moving when up and down moves balance, so it flattens out in consolidations".

What is the VIDyA formula?

Three lines, MetaTrader's formula written out:

EMA(i)   = Price(i) * F + EMA(i-1) * (1-F)
           F = 2/(Period_EMA+1)

VIDYA(i) = Price(i) * F * ABS(CMO(i)) + VIDYA(i-1) * (1 - F * ABS(CMO(i)))

CMO(i)   = (UpSum(i) - DnSum(i)) / (UpSum(i) + DnSum(i))

The middle line is an ordinary EMA whose smoothing factor is F times ABS(CMO), and everything specific to the indicator sits in that multiplication.

Then the scale. Printed like that, CMO is a bare fraction running from -1 to +1, a difference divided by a sum. Chande's own oscillator does not. The same library's specification for the unsmoothed Chande Momentum Oscillator, the one this average uses, gives it as 100 * (Su-Sd)/(Su+Sd) and states the range as "Bounded in [-100,+100]". Its page for this average also writes the averaging step with the scale impossible to lose. Its alpha is 2 divided by the EMA period n plus 1. Each bar's smoothing factor k is alpha times the absolute value of the CMO, divided by 100. The new VIDYA is the previous VIDYA plus k times the gap between the current price and the previous VIDYA.

Same calculation, with the division by 100 explicit. With |CMO| as a fraction between 0 and 1 the two agree exactly. A 38 pasted into a line expecting 0.38 does not, and MetaQuotes' 2010 code base page and tradingpedia.com both republish the vendor's three lines with the same unlabelled fraction, so the trap travels with the formula.

A published formula that is not this indicator

markets.com's education page publishes a different calculation, with no Chande Momentum Oscillator on it at all. It builds the line in three separate steps, a variable index, then a smoothing factor, then the average itself, and its formulas come to this:

VI = ABS(Close - Close[n]) / Close[n]
SF = 2 / (VI + 1)
VIDYA = SF * Close + (1 - SF) * VIDYA[1]

Its VI is a percentage change written as a fraction, so 2/(VI+1) gives a smoothing factor above 1 for every move smaller than 100 percent over n bars. A 1 percent move gives SF = 1.9802, so the line reads 1.9802 x Close - 0.9802 x previous, and a 0.1 percent move gives 1.9980. A negative weight on a line's own previous value does no smoothing, and a line built that way sits past the price on nearly every bar. The same page also reads the name as a description of the method: "The calculation of VIDYA involves two key components: the variable index and the dynamic average." Neither names a quantity in the formula above.

Does ChartLabs have it?

Yes. It is in the chart's Indicators menu, in the Standard list under Moving Averages, named Variable Index Dynamic Average, and it draws on the price pane rather than in a pane of its own. Two settings carry the formula, Length 12 and CMO Length 9, with Source on the close: Length is the EMA period, which is the ceiling on how fast the line can ever be, and CMO Length is the oscillator's own window.

Ours computes Chande's 1995 form, with the averaging step written out above, and the oscillator driving it is the unsmoothed one, raw up moves and down moves summed over the window. That is fixed in the build rather than offered as a choice, so the Wilder-smoothed variant is a line ours never draws. On a dead flat window ours reads 0 for the oscillator, which means the line holds its last value instead of dividing zero by zero.

What does the Chande Momentum Oscillator do in it?

It decides how much of today's price gets into the line. The oscillator compares the sum of the up moves with the sum of the down moves over its own window: all up gives +100, all down gives -100, an even balance gives 0. Only the absolute value is used, so direction is discarded, and the average asks only how one-sided the recent movement has been.

At |CMO| near its maximum the moves ran nearly all one way, the smoothing factor is close to the full F, and the line behaves like the EMA you set. At |CMO| near 0 the up and down moves cancelled, the factor shrinks towards nothing, and the line goes nearly inert.

One case the vendor's page leaves out: if nothing moves at all, both sums are zero and (UpSum - DnSum)/(UpSum + DnSum) is zero divided by zero. The open-source library fills that hole by decree, with the oscillator "0 when Su+Sd == 0 (an exactly flat window)". Treating a motionless window as perfectly balanced is a choice rather than arithmetic, so what your chart draws on such a bar is your platform's decision.

A worked example with round numbers

An example, not a recommended setting. CMO period 9, Period_EMA 9, so F = 2/(9+1) = 0.2.

Prices: 100, 101, 100, 102, 101, 103, 102, 104, 103, 105. Nine changes: +1, -1, +2, -1, +2, -1, +2, -1, +2.

  • UpSum = 1 + 2 + 2 + 2 + 2 = 9
  • DnSum = 1 + 1 + 1 + 1 = 4
  • CMO as the vendor prints it = (9 - 4) / (9 + 4) = 5/13 = 0.3846, which is 38.46 on Chande's scale
  • Weight on today's price = 0.2 x 0.3846 = 0.0769
  • Previous VIDyA 102.0000, current price 105, so VIDyA = 0.0769 x 105 + 0.9231 x 102 = 102.2308

A smoothing factor of 0.0769 is the factor of a 25-bar EMA. The dialog says 9, the market was moderately one-sided, and the line is averaging like a 25-bar average.

Why is my VIDyA so slow, and why does it sometimes stop moving?

Because it can only ever be slower than the EMA period you set. The weight on today's price is F x |CMO|, and |CMO| is at most 1, so that weight is at most F. The plain EMA is the best case.

Here is the range at Period_EMA = 9, where F = 0.2. A smoothing factor c corresponds to an EMA of period 2/c - 1, with a half-life of log(0.5)/log(1-c) bars. This is arithmetic on the published formula and the bound |CMO| <= 1, not a measurement of any market.

|CMO| (fraction scale)Weight on today's priceBehaves like an EMA ofHalf-life
1.00, all moves one way0.209 bars3.1 bars
0.500.1019 bars6.6 bars
0.250.0539 bars13.5 bars
0.100.0299 bars34.3 bars
0.050.01199 bars69.0 bars
0, perfectly balanced0does not movenever

A setting of 9 is the fastest a 9 can ever be, reached only when every move in the window went the same way, and a mildly choppy stretch puts you at 39 or 99 bars without anyone touching a setting. The last row is literal: at |CMO| = 0 the weight on price is exactly 0, the recursion reads VIDYA(i) = VIDYA(i-1), and the line holds its last value until the up and down sums stop cancelling. A flat VIDyA in a range is the formula doing what it says, not a rendering fault or a stuck feed.

So pages that describe the indicator as speeding up "when a strong steady trend takes place", as FXCM's help page does, have it backwards. The adaptation releases a brake, and there is no accelerator in the formula.

The scale trap shows up here too. Paste a real oscillator reading on the -100 to +100 scale into the vendor's line and an ordinary |CMO| = 50 with Period_EMA = 9 puts a weight of 10 on today's price and -9 on the previous value. At 100 it is 20 and -19.

Which VIDyA is on my chart?

Possibly not the one whose formula you read, because at least three lines are published under the name.

Chande's 1992 form and his 1995 form are different indicators by the same author. The library that specifies the 1995 version says that "Chande's 1992 article drives the same step with a ratio of standard deviations; this is his 1995 form, driven by the CMO", and dates the two to Technical Analysis of Stocks & Commodities V.10:3 (March 1992) and V.13:10 (October 1995), the second being "The CMO as the volatility index, with the 12 and 9 periods". FXCM's help page adds a middle date: the indicator "was modified and presented in The New Technical Trader by Tushar Chande and Stanley Kroll, John Wiley and Sons, New York, 1994". A page naming only one of 1992, 1994 and 1995 is not telling you which line it means.

The third line comes from a choice inside the oscillator. Chande's original CMO uses plain period sums, and the same library also ships a Wilder-smoothed variant that smooths the gains and losses instead. An implementation driven by that one "computes a different line that does not converge to this one", in the library's words.

Third-party scripts then wrap the average in volume or volatility bands under their own names. TradingView's listing for the name is a community script category with 18 publications on it, 16 labelled Indicator and 2 labelled Strategy, where one description has the indicator measuring volatility by the standard deviation of price, another repeats the MetaQuotes CMO text word for word, and a third works from "the relationship between short-term and long-term volatility".

What are the best VIDyA settings?

There is no agreement to report. What each source publishes:

SourcePeriods exposedPublished values
The open-source TA-Lib libraryTwo: the EMA length and the CMO lengthDefaults 12 and 9, accepted 1 to 100000 and 2 to 100000, "Chande's 12:9 ratio"
MetaTrader 5 helpTwo: "period of CMO and period of EMA"None published
MQL5 referenceTwo, as cmo_period and ema_periodNone published
FXCM Marketscope helpOne, "Number of periods"Default 9, "The commonly used values are 7, 14, 26, and 52"
ChartLabsTwo: Length, the EMA period, and CMO LengthDefaults 12 and 9, the same pair

The 12 and 9 are the library's defaults and Chande's ratio rather than a platform default: neither MetaTrader page publishes a default for either period. FXCM exposes a single number where the formula has two, without saying which of the two it sets, so a setting copied between platforms may not be setting the same thing.

The EMA period sets the fastest the line can ever be, the ceiling in the table. The CMO period sets how long a window decides how one-sided the move was: a short one lets the brake off quickly, a long one keeps it on through short bursts.

Is VIDyA on MT4, MT5 or TradingView?

MT5 has it built in, in the vendor's Trend Indicators list alongside the Adaptive Moving Average and the Fractal Adaptive Moving Average. MQL5 exposes it as a function, iVIDyA(symbol, period, cmo_period, ema_period, ma_shift, applied_price), with "only one buffer": one line, no signal line, and no bands drawn for you. MT4 does not have it. The vendor's technical indicator index lists 29 indicators, and neither this nor any other adaptive moving average is among them, so on MT4 it would be a custom indicator. On TradingView the name resolves to the community script category, and whether a built-in exists is not stated there.

Note the applied_price argument in the MQL5 signature. Which price the average is computed on is a setting, so two charts with the same two periods can differ for that reason alone.

How do you read a VIDyA?

Sources mostly read the bands rather than the line. MetaTrader's help page says "Usually not VIDYA itself is used in trading systems, but its upper and lower borders (Upper band & Lower band), that are by N% above and below VIDYA", interpreted "similar to Bollinger Bands". FXCM's help page goes further into instructions, saying that "Steadily descending band lines are a signal to open Sell positions, and steadily ascending ones are a good signal to open Buy positions". No test accompanies that sentence, and the same page claims the indicator "allows making less mistakes in trading decisions".

The reading specific to this indicator is the flat line, which says the up and down moves in the window have cancelled. A slow VIDyA and a frozen VIDyA look identical on a chart and mean different things, and the oscillator reading separates them.

How is it different from a KAMA or a FrAMA?

All three are an EMA whose smoothing factor is recomputed every bar, and they differ in the measurement that does it. A KAMA uses an efficiency ratio, net movement divided by total movement, and blends a fast and a slow constant with it: see the Kaufman adaptive moving average. A FrAMA derives its factor from a fractal dimension estimated from high-low ranges: see the fractal adaptive moving average. A VIDyA scales one constant by the absolute Chande Momentum Oscillator.

The practical difference is the ceiling. A VIDyA's weight on today's price cannot exceed the EMA constant you set, so it has no mechanism for overshooting the price.

How do you test a VIDyA rule?

Write down what a second person would need to reproduce your chart, before the first bar: the symbol and timeframe, both periods (a result on 12 and 9 says nothing about 12 and 30), which price the average is applied to, what counts as the event, and what you do on the bar it happens.

Testable: "on completed 4-hour candles of EURUSD, price closes above VIDyA(EMA 12, CMO 9) applied to close, having closed below it for at least three candles, and I enter at the next candle's open with a stop below the prior swing low." Not testable: "the VIDyA turned up." If your platform does not publish which of the three lines it draws, your rule is reproducible only on that platform, so record which one you used.

Then run it on one symbol, one timeframe and one date range, with the settings fixed throughout, every trade written down including the ones you decided against, and costs applied, because an adaptive line produces clusters of entries when conditions turn. Record the oscillator reading at entry if your platform shows it: it is the only number that says which filter was running on that bar.

That suits stepping through bars by hand, because the question is what the line looked like on the bar you had to decide. On ChartLabs you replay real historical candles one at a time and place the trades yourself, with per-symbol commission and slippage feeding every trade's P&L, balances and analytics. Write both periods and the price source down with each trade, since a result on 12 and 9 says nothing about another pair. There is no automatic backtest of an indicator here, so the counting stays yours to do on the replay.

Where does it fall apart?

It is never faster than its own EMA setting, so the number in your dialog is a ceiling you reach only in a one-sided window. It can stop moving entirely, because at a balanced oscillator the weight on price is zero, and a perfectly flat window is undefined in the published formula. The oscillator's scale is not printed with the formula, so a reading taken from elsewhere puts a negative weight on the previous value. The same name covers at least three different lines, and one platform gives you a single setting where the formula has two. And the published band rules are framed as signals to buy and sell with no trade count behind them.

Next step

ChartLabs has the Variable Index Dynamic Average built in, and bar-by-bar replay to step through it with costs applied per symbol. One plan, $20 a month or $200 a year, with a 7-day free trial and no credit card required: start the free trial.

Related reading: how to backtest a strategy step by step, forex backtesting, and why backtest results and live results drift apart.

Related Topics

variable-index-dynamic-averagevidyachande-momentum-oscillatoradaptive-moving-averagemoving-averagesbacktesting