Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Kruppy
You could use the following formula for ADX, and use the Prec() function with the output line to set the number of decimal places for the result. One or two decimal places should be all you'd need.
I think the PDI() and MDI() functions in MetaStock (also produced by this formula) use rounding too. Rounding appears to be the main difference between this formula and the "Directional Movement ADX" function in MetaStock.
Don't take any notice of the "ADX Raw" tag. That's just what I use to identify it.
{MetaStock code written by Equis and published in the Oct99 TASC}
{ADX Raw}
Periods:=Input("Enter time periods",1,100,14);
PlusDM:=If(H>Ref(H,-1) AND
L>=Ref(L,-1),H-Ref(H,-1),
If(H>Ref(H,-1) AND L<Ref(L,-1)
AND H-Ref(H,-1)>Ref(L,-1)-L,
H-Ref(H,-1),0));
DIPlus:=100*Wilders(PlusDM,Periods)/ATR(Periods);
MinusDM:=If(L<Ref(L,-1) AND
H<=Ref(H,-1),Ref(L,-1)-L,
If(H>Ref(H,-1) AND L<Ref(L,-1)
AND H-Ref(H,-1)<Ref(L,-1)-L,
Ref(L,-1)-L,0));
DIMinus:=100*Wilders(MinusDM,Periods)/
ATR(Periods);
DIDif:=Abs(DIPlus - DIMinus);
DISum:=DIPlus + DIMinus;
100*Wilders(DIDif/DISum,Periods);
Roy
MetaStock Tips & Tools
|