#### samiranadhikari

##### Member

I would love to see thinkscript for the following code for vidya 2 indicator (motivewave). I found this indicator very useful.

VIDYA2 Indicator by Chande and Kroll are types of Adaptive Moving Averages that use Standard Deviation and feedback in their calculation. Two paths are plotted with different alpha values.

Code:

```
//input = user defined, default is close
//period = user defined, default is 20
//alpha1 = user defined, default is .2
//alpha2 = user defined, default is .04
//prev = previous, index = current bar number
//std = stdDev = standard deviation
stdDev = std(index, period, input);
avStdDev = ma(method, index, period, stdDev);
prevVidya1 = isNull(price, vidya1[index-1]); //feedback
prevVidya2 = isNull(price, vidya2[index-1]); //feedback
ratio = stdDev/avStdDev;
Plot1: vidya1 = (alpha1 * ratio * price) + ((1-(alpha1*ratio)) * prevVidya1);
Plot2: vidya2 = (alpha2 * ratio * price) + ((1-(alpha2*ratio)) * prevVidya2);
//Signals
buy = crossedAbove(VIDYA1, VIDYA2);
sell = crossedBelow(VIDYA1, VIDYA2);
```

VIDYA2 Indicator by Chande and Kroll are types of Adaptive Moving Averages that use Standard Deviation and feedback in their calculation. Two paths are plotted with different alpha values.

Last edited by a moderator: