input: n(9,1,60), p(2,1,60), Q(30,1,60);
Direction:=CLOSE - REF( CLOSE , N ) ;
XX:=ABS( CLOSE - REF( CLOSE , 1 ) ) ;
Volatility:=SUM( XX , N ) ;
ER:=ABS( Direction / Volatility ) ;
FastC:= 2 / ( p + 1 ) ;
SlowC:= 2 / ( q + 1 ) ;
SSC:=ER * ( FastC - SlowC ) + SlowC ;
Constant :SSC * SSC , Linethick0 ;
YY:=REF( Close , 1 ) + Constant * ( CLOSE - REF( Close , 1 ) ) ;
AA:=IF( SUM( 1 , 0 )= N + 1 , YY , 0 ) ;
BB:=BarsLast( AA>0 ) ;
DD:=REF( C , BB ) ;
CC:CLOSE , Linethick0 ;
for m=N + 2 to DATACOUNT DO
DD[m]:=DD[m - 1] + Constant[m] * ( CC[m] - DD[m - 1] );
AMA:DD;
T1:=DD>REF(DD,1);
T3:=NOT(T1) AND abs(DD-ref(DD,1))/DD*10000<N;
T2:=NOT(T1 OR T3);
PARTLINE(T1,DD),COLORRED,LINETHICK2;
PARTLINE(T2,DD),COLORGREEN,LINETHICK2;
PARTLINE(T3,DD),COLORBLUE,LINETHICK2;
DRAWTEXT(ISLASTBAR AND T1,DD,'持\n股'),COLORRED,SHIFT1;
DRAWTEXT(ISLASTBAR AND T2,DD,'持\n币'),COLORGREEN,SHIFT1;
DRAWTEXT(ISLASTBAR AND T3,DD,'观\n望'),COLORBLUE,SHIFT1;