Type : Indicator, Name : VIDYA/CDMA
Input:
Len(10);
Vars:
Diff(0),
MyConst(0),
MyAdx(0),
Varma(0),
EmaIndex(0);
{. Index of EMA .}
If Len > 0 then EmaIndex = (2 / (1 + Len)) else EmaIndex = 0.20;
{. Stochastic oscillator using ADX .}
MyAdx = ADX(20);
Diff = Highest(MyAdx, 20) — Lowest(MyAdx, 20);
If Diff > 0 then MyConst = (MyAdx — Lowest(MyAdx, 20))/Diff else MyConst = EmaIndex;
{. Clamp length to that implied by input value of Len .}
If MyConst > EmaIndex then MyConst = EmaIndex;
{. Create the variable MA .}
If CurrentBar < 50 then Varma = Close else Varma = (1 — MyConst) * Varma[1] + MyConst * Close;
Plot1(Varma, «VarMA») ;
Plot2(XAverage(Close, Len), «XAvg»)