T:=20;N:=2;M:=30;
DIRECTION:=CLOSE-REF(CLOSE,T);
volATILITY:=SUM(Abs(CLOSE-REF(CLOSE,1)),T);
ER:=SUM(ABS(DIRECTION/VOLATILITY),1);
FastC:=2/(N+1);
SlowC:=2/(M+1);
Smooth:=ER*(FastC-SlowC)+slowC;
SE:=Smooth*Smooth;
YY:=REF(Close,1)+SE*(Close-Ref(Close,1));
AA:=IF(SUM(1,0)=T+1,YY,0);
BB:=BArslAST(AA>0);
CC:=REF(Close,BB);
AMA:REF(CC,1)+SE*(Close-REF(CC,1));