N:=5;K:=3;p:=13;DIRECTION:=A(CLOSE-REF(CLOSE,N));ATILITY:=SUM(ABS(CLOSE-REF(CLOSE,1)),N);ER:=DIRECTION/ATILITY;FSC:=2/(2+1);SSC:=2/(30+1);SC:=ER*(FSC-SSC)+SSC;SCSQ:=SC*SC;KMA:=DMA(CLOSE,SCSQ),colorblue;THRESHOLD:=STD(KMA-REF(KMA,1),20)*K/10;A:=CLOSE-REF(CLOSE,P);MI:=(A,P,1);