{MA20:MA(C,20),COLORGREEN;
EMA20:EMA(C,20),COLORYELLOW;
SMA20:SMA(C,20,1),COLORFF00FF;
DRAWKLINE(H,O,L,C);}
{KAMA}
N:=20;
P:=3;
DIR1:=ABS(CLOSE-REF(CLOSE,N));
VIR1:=SUM(ABS(CLOSE-REF(CLOSE,1)),N);
ER1:=DIR1/VIR1;
CS1:=ER1*(0.8-2/8)+2/8;
CQ1:=CS1*CS1;
AMA1:=DMA(CLOSE,CQ1),COLORWHITE;
{CLMA}
SG:=SUM(TR, N);
RE1:=ABS(C-REF(C,N));
RE2:=HHV(H,N)-LLV(L,N);
RE:=RE2/SG;
A:=(RE/SUM(TR, N));
AMA_CL:=A*C+(1-A)*REF(AMA1,1);
CLMA:EMA(AMA_CL,P),COLORWHITE,LINETHICK2;