## Chandes Variable Index Dynamic Average VIDYA2

Tushar Chande's Variable Index Dynamic Average (VIDYA) first appeared in Technical Analysis of Stocks & Commodities in March 1992. Both VIDY\ and Kaufman's KAMA use an exponential smoothing as a base for varying the speed of the trend each day. VIQXA, however, uses a pivotal smoothing constant, which is fixed, and varies the speed by using a factor based on the relative volatility to increase or decrease the value of 5.

VIDYA, = AxsxC, + (l-fexs) x VJDYA,.i where s is a fixed smoothing constant, suggested as a 9-day equivalent (i.e., 5 = 2/(9 + 1) = -20) C is the closing price

2 Tushar S. Chande and Stanley Kroll, The New Technical Trader (John Wiley & Sons, New York, 1994).

t and / — 1 represent the current and previous periods k is the relative volatility, calculated as k = @stdev(C,n) / @stdev(C,m)

where @stdev is the standard deviation function n is the recent past n days m is a longer historic interval in days, m> n

### Volatility

Chande uses a very practical relative volatility measure based on the standard deviation, or distribution of price moves over the past n days, compared with a longer historic pattern, taken over h days. When k > 1 the current volatility is greater than the historic volatility; when k < 1 the current volatility is lower. VIDYA can be written as an indicator in Omega code as

{VIDYA : Variable Index Dynamic Average by Tushar Chande Copyright 1997-1998, PJ Kaufman. All rights reserved. Period suggested at 9, histper suggested ,at > 9} input: period(9), histper(30); var: k(0), sc(0) , VIDYA(O);

(relative volatility)

k - @stddev(close, period) / @stddev(close,histper); (smoothing constant)

IVIDYA)

VIDYA - k*sc*close + Cl - k*sc)*VIDYA; plotl C VIDYA, "VIDYA"); "'

### Alternate Choices for Varying the Trend Period

The use of an exponential formula, either the simplified one shown by Kaufman or the traditional one of Chande, allows the smoothing constant to vary according to the design of the user. There are indicators with which we are already familiar that might be substituted for the smoothing constant.

Correlation Coefficient, r2

The most likely choice, suggested by Chande, is the correlation coefficient, r2. This value is the result of measuring the residuals from a linear regression calculation. When the regression fit is very strong, the value of r2 is near 1; when there is no apparent market direction, r2 is near 0. This fits neady into the same pattern of smoothing constants as the KAMA and VIDYA.

When programming this technique, the calculation of the correlation of the residuals, r, requires the use of arrays and your own code for the correlation. This can be done using the formulas found in Chapter 3. To avoid that complication, the following program calculates a similar technique (Method 1) by evaluating the correlation of the closing prices and a time series containing the sequential values 1,2,3,. . • It then calculates the current value of the residual based on a linear regression of closing prices (Method 2) and finds the correlation coefficient, r2, of the series of current residuals. In the following programming code Method 2 is plotted, and the result of Method 1 is commented out.

{Adaptive R2 : Adaptive Correlation Coefficient Indicator Copyrigh t=-1997 -1998, PJ Kaufman. All rights reserved. Plot smoothing function "based on linear regression residuals and on simple time series function)

input: period(97;

var: R2(Q), AR2C0), timeserles(0), resid(O), RR2(0), ARR2(0);

timeseries = currentbar; (Method 1: correlation of price and timeseries) if currentbar <= period then AR2 - close else begin

R2 = (@correlation(close, timeseries, period) + 1) / 2; AR2 - AR2 + R2*(close - AR2 );

end;

(Method 2: correlation with current regression residual ) resid = close - @1inearregvaIue(close,period,0); RR2 - (@correlation(resid, timeseries, period) + 1) / 2; ARR2 - ARR2C1] + RR2*(cIose - ARR2); plot2 tARR2,"ARR2"); 