PureBytes Links
Trading Reference Links
|
Hi List,
Please pardon my EL gimpiness, but can someone please show me how this can
be turned into a function (without the XAverage ie just the Varma):
************************************************************
{Tushar Chande 2001: 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")
*****************************************************************
I tried this (don't laugh), naming the function Varma but got an error msg.
that "a value was never assigned to user function":
Input: Len(Numeric);
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;
Thanks in advance.
David
|