N1:=6;N2:=12;N3:=26;
MA6:MA(CLOSE,6),COLORWHITE{,LINETHICK2};
MA18:MA(CLOSE,18),COLORBLUE{,LINETHICK2};
A:=(3*C+L+O+H)/6;
X:=(20*A+19*REF(A,1)+18*REF(A,2)+17*REF(A,3)+16*REF(A,4)+15*REF(A,5)+
14*REF(A,6)+13*REF(A,7)+12*REF(A,8)+11*REF(A,9)+10*REF(A,10)+9*REF(A,11)+8*REF(A,12)
+7*REF(A,13)+6*REF(A,14)+5*REF(A,15)+4*REF(A,16)+3*REF(A,17)+2*REF(A,18)+
REF(A,20))/210;
庄成本:EMA(X,13),COLORRED,LINETHICK2;
MTM:=C-REF(C,1);
DX:=100*EMA(EMA(MTM,6),6)/EMA(EMA(ABS(MTM),6),6);
买:IF(LLV(DX,2)=LLV(DX,7) AND COUNT(DX<0,2) AND CROSS(DX,MA(DX,2)),1,0),COLORRED;
卖:IF(HHV(DX,2)=HHV(DX,7) AND COUNT(DX>50,2) AND CROSS(MA(DX,2),DX),1,0),COLOR00FF00;
DRAWTEXT(FILTER(买=1,5),LOW-0.03,'买'),COLORRED;
STICKLINE(FILTER(买=1,5),HIGH,LOW,0,1),COLORRED{,LINETHICK2};
STICKLINE(FILTER(买=1,5),OPEN,CLOSE,4,1),COLORRED{,LINETHICK2};
DRAWTEXT(FILTER(卖=1,1),HIGH*1.02,'卖'),COLORBLUE;
STICKLINE(FILTER(卖=1,1),HIGH,LOW,0,1),COLORBLUE{,LINETHICK2};
STICKLINE(FILTER(卖=1,1),OPEN,CLOSE,4,1),COLORBLUE{,LINETHICK2};
加仓A:=SMA(EMA((C-REF(C,1))/REF(C,1),5)*100,3,1)*10;
追:IF(MA18>=REF(MA18,3) AND CROSS(CLOSE,MA18),1,0),COLORYELLOW;
DRAWTEXT(MA18>=REF(MA18,3) AND CROSS(CLOSE,MA18),LOW*0.96,'追'),COLORYELLOW;
STICKLINE(MA18>=REF(MA18,3) AND CROSS(CLOSE,MA18),HIGH,LOW,0,1),COLORYELLOW{,LINETHICK2};
STICKLINE(MA18>=REF(MA18,3) AND CROSS(CLOSE,MA18),OPEN,CLOSE,4,1),COLORYELLOW{,LINETHICK2};
RSV:=(C-LLV(L,9))/(HHV(H,9)-LLV(L,9))*100;
K:SMA(RSV,3,1),COLORFFFFFF;
D:SMA(K,3,1),COLOR00FFFF;
J:3*K-2*D,COLORFF00FF;
BDGD:=HHV(J,2)=HHV(J,8) AND J>80;
减仓:IF(CROSS(REF(J-0.01,1),J) AND REF(BDGD,1),1,0),COLOR006633;
RSV1:=(C-LLV(LOW,13))/(HHV(H,13)-LLV(L,13))*100;
RSV2:=(CLOSE-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))*100;
K2:=SMA(RSV2,3,1);
D2:=SMA(K2,3,1);
J2:=3*K2-2*D2;
TY:=C;
HD:=FILTER(BACKSET(FILTER(REF(TY,10)=HHV(TY,2*10+1),10),10+1),10);
LD:=FILTER(BACKSET(FILTER(REF(TY,10)=LLV(TY,2*10+1),10),10+1),10);
A2:=REF(C,BARSLAST(HD));
B2:=REF(C,BARSLAST(LD));
T1:=BARSLAST(HD)<BARSLAST(LD) AND NOT(HD) ;
T2:=BARSLAST(HD)>BARSLAST(LD) AND NOT(LD);