SHZB:=CODELIKE('60');{上证主板}
KCB:=CODELIKE('68');{科创板}
SZZB:=CODELIKE('00');{深证主板}
CYB:=CODELIKE('30');{创业板}
BZ:=INBLOCK('北证A股');
KZZ:=CODELIKE('11') OR CODELIKE('12');{可转债}
GP:=SHZB OR KCB OR SZZB OR CYB;
L1:=IF(KCB OR CYB OR KZZ,0.2,IF(INBLOCK('ST板块'),0.05,IF(BZ,0.3,0.1)));{取涨停值}
ZTJ:=ZTPRICE(REF(CLOSE,1),L1);{计算当前K线的涨停价}
Z1:=ZTJ=C;{涨停}
Z2:=ZTJ=H AND C
STICKLINE(GP OR KZZ OR BZ AND Z2 AND PERIOD=5,C,O,-1,0),RGBXF1C232;
{异动及严重异动提示}
PLZ:=IF(KCB OR CYB,30,20);{各市场股票构成异动所对应的涨幅偏离值}
TM:=IF(SHZB AND DATE>=1230410,1,IF(SZZB AND DATE>=1220713,1,0));{上证主板、深证主板全面注册制异动新规实施时间}
GGLJ2:=SUM((C/REF(C,1)-1),2)*100;{个股两日累加涨跌幅}{适用于全面注册制异动新规实施前}
GGLJ3:=SUM((C/REF(C,1)-1),3)*100;{个股三日累加涨跌幅}
GGQJ2:=(C/REF(C,2)-1)*100;{个股两日区间涨跌幅}{适用于全面注册制异动新规实施后}
GGQJ3:=(C/REF(C,3)-1)*100;{个股三日区间涨跌幅}
ZSLJ2:=IF(SHZB,SUM("999998$C"/REF("999998$C",1)-1,2),IF(SZZB,SUM("399106$C"/REF("399106$C",1)-1,2),0))*100;{A股指数、深证A指两日累加涨跌幅}{适用于全面注册制异动新规实施前}
ZSLJ3:=IF(SHZB,SUM("999998$C"/REF("999998$C",1)-1,3),IF(SZZB,SUM("399106$C"/REF("399106$C",1)-1,3),0))*100;{A股指数、深证A指三日累加涨跌幅}
ZSQJ2:=IF(SHZB,"999998$C"/REF("999998$C",2)-1,"399107$C"/REF("399107$C",2)-1)*100;{A股指数、深证A指两日区间涨跌幅}{适用于全面注册制异动新规实施后}
ZSQJ3:=IF(SHZB,"999998$C"/REF("999998$C",3)-1,"399107$C"/REF("399107$C",3)-1)*100;{A股指数、深证A指三日区间涨跌幅}
XXQJ2:=IF(CYB,"399102$C"/REF("399102$C",2)-1,IF(KCB,"SH000688$C"/REF("SH000688$C",2)-1,0))*100;{创业板综、科创50两日区间涨跌幅}
XXQJ3:=IF(CYB,"399102$C"/REF("399102$C",3)-1,IF(KCB,"SH000688$C"/REF("SH000688$C",3)-1,0))*100;{创业板综、科创50三日区间涨跌幅}
R2:=IF(KCB OR CYB,GGQJ2-XXQJ2>=PLZ,IF(TM=0,GGLJ2-ZSLJ2>=PLZ,GGQJ2-ZSQJ2>=PLZ));{个股两日异动}
R3:=IF(KCB OR CYB,GGQJ3-XXQJ3>=PLZ,IF(TM=0,GGLJ3-ZSLJ3>=PLZ,GGQJ3-ZSQJ3>=PLZ));{个股三日异动}
{10个交易日内的连续同向异动统计}
YD:=R2 OR R3;
YD1:=YD AND EXISTR(YD,5,1)=0 AND COUNT(AMO>0,0)>5;{前5日内无异动,且上市天数大于5}{10日内第1次异动}
SJ1:=BARSLAST(YD1);{第一次异动距今交易日}
T1:=R2 AND SJ1>=2;{若第二次异动为两日异动,则距离第一次异动至少两个交易日}
T2:=R3 AND SJ1>=3 AND REF(T1,1)=0;{若第二次异动为三日异动,则距离第一次异动至少三个交易日}{前一日不存在两日异动}
YD2:=T1 OR T2 AND COUNT(T1 OR T2,SJ1)=1 AND SJ1<=9;{第一次异动至今,两日或三日异动有且只有一次}{且距离第一次异动不超过9个交易日}{10日内第2次异动}
SJ2:=BARSLAST(YD2);{第二次异动距今交易日}
T3:=R2 AND SJ2>=2 AND SJ2
SJ3:=BARSLAST(YD3);
T5:=R2 AND SJ3>=2 AND SJ3
SJ4:=BARSLAST(YD4);
T7:=R2 AND SJ4>=2 AND SJ4
SJ5:=BARSLAST(YD5);
{10个、30个交易日内涨幅偏离值分别达到100%、200%统计}
W1:=LLVBARS(C,11);{11个交易日内最低收盘价距今周期数}
W2:=LLVBARS(C,31);{31个交易日内最低收盘价距今周期数}
V1:=C/REF(C,W1)-1;{个股11个交易日内最低收盘价距今涨跌幅}
V2:=C/REF(C,W2)-1;{个股31个交易日内最低收盘价距今涨跌幅}
P1:=IF(SHZB,"999998$C"/REF("999998$C",W1)-1,IF(CYB,"399102$C"/REF("399102$C",W1)-1,IF(KCB,"SH000688$C"/REF("SH000688$C",W1)-1,"399107$C"/REF("399107$C",W1)-1)));{W1期间指数涨跌幅}
P2:=IF(SHZB,"999998$C"/REF("999998$C",W2)-1,IF(CYB,"399102$C"/REF("399102$C",W2)-1,IF(KCB,"SH000688$C"/REF("SH000688$C",W2)-1,"399107$C"/REF("399107$C",W2)-1)));{W2期间指数涨跌幅}
GL1:=IF(KCB OR CYB,3,6);
GL2:=IF(KCB OR CYB,6,11);
X1:=FILTER(V1-P1>=1,GL1);{个股10个交易日内涨幅偏离值>=100%}{其后3或6个交易日不再显示该异动}
X2:=FILTER(V2-P2>=2,GL2);{个股30个交易日内涨幅偏离值>=200%}{其后6或11个交易日不再显示该异动}
CY101:=X1 AND EXISTR(X1,9,1)=0 AND EXISTR(X2,9,1)=0 AND DATE>=1230103;{创业板个股10日内首次涨幅偏离值>=100%}
CYT1:=BARSLAST(CY101);{创业板个股首次涨幅偏离值>=100%距今周期数}
V3:=C/REF(C,CYT1)-1;{创业板个股首次涨幅偏离值>=100%距今涨幅}
P3:="399102$C"/REF("399102$C",CYT1)-1;{期间创业板综指数涨幅}
G1:=V3-P3>=1;{偏离值计算}
CY102:=G1 AND COUNT(G1,CYT1)=1 AND DATE>=1230101;{第二次涨幅偏离值大于100%}
CY201:=X2 AND EXISTR(X1,29,1)=0 AND EXISTR(X2,29,1)=0;{30日内不存在涨幅严重异动,首次涨幅偏离值大于200%}
G2:=V3-P3>=2;
CY202:=G2 AND COUNT(G2,CYT1)=1 AND DATE>=1230101;{30日内存在10日涨幅偏离值大于100%严重异动,首次涨幅偏离值大于200%}
Y1:=X1 AND EXISTR(X1,9,1)=0;
Y2:=X2 AND EXISTR(X2,29,1)=0;
{创业板10日内存在涨幅偏离值严重异动,重新计算异动次数}
CY3:=EXISTR(Y1,9,1) OR EXISTR(Y2,9,1) AND YD3 AND CYB;
CY4:=EXISTR(CY3,5,1) AND YD4 AND CYB;
{超出首次10日内计数范围,但前5日存在异动,重新计数}
JK1:=EXISTR(YD2,5,1) AND EXISTR(YD3,5,1)=0 AND SJ2>=2 AND SJ2
K1:=EXISTR(YD3,5,1) AND EXISTR(YD4,5,1)=0 AND SJ3>=2 AND SJ3
K3:=EXISTR(YD4,5,1) AND EXISTR(YD5,5,1)=0 AND SJ4>=2 AND SJ4
K5:=EXISTR(YD5,5,1) AND SJ5>=2 AND SJ5
YDX:=FILTER(JK OR J1 OR J2 OR J3 AND SJ1>9,3);{前5日存在异动}
SJ6:=BARSLAST(YDX);
U2:=R2 AND SJ6>=2;
U3:=R3 AND SJ6>=3 AND REF(U2,1)=0;
YDX2:=U2 OR U3 AND COUNT(U2 OR U3,SJ6)=1 AND SJ6<=9 AND EXISTR(YDX,5,1);{10日内第2次异动}
SJ7:=BARSLAST(YDX2);
U4:=R2 AND SJ7>=2 AND SJ7
{深证主板第4次异动}
SZZB4:=EXISTR(Y1,9,1)=0 AND EXISTR(Y2,9,1)=0 AND YD4 AND SZZB;{10日内第4次异动,且前9日无严重异动}
XJ:=BARSLAST(SZZB4);
SZZB1:=EXISTR(Y1,9,1) OR EXISTR(Y2,9,1) AND YD4 AND SZZB;{前9日存在涨幅严重异动,重新计算异动次数}
SJ8:=BARSLAST(SZZB1);
B1:=R2 AND SJ8>=2;
B2:=R3 AND SJ8>=3 AND REF(B1,1)=0;
SZZB2:=B1 OR B2 AND COUNT(B1 OR B2,SJ8)=1 AND SJ8<=9 AND EXISTR(SZZB1,5,1);
SJ9:=BARSLAST(SZZB2);
B3:=R2 AND SJ9>=2 AND SJ8>SJ9;
B4:=R2 AND SJ9>=3 AND SJ8>SJ9 AND REF(B3,1)=0;
SZZB3:=B3 OR B4 AND COUNT(B3 OR B4,SJ9)=1 AND SJ8<=9 AND EXISTR(SZZB2,5,1);
{深证主板超出首次计数范围,但前5日存在异动,重新计数}
D3:=EXISTR(SZZB4,5,1) AND XJ>=2 AND XJ
SZ1:=FILTER(J1 OR D5 AND SJ1>9,3);
SS1:=BARSLAST(SZ1);
C1:=SS1>=2 AND R2;
C2:=SS1>=3 AND R3 AND REF(C1,1)=0;
SZ2:=C1 OR C2 AND COUNT(C1 OR C2,SS1)=1 AND SS1<=9 AND EXISTR(SZ1,5,1);
SS2:=BARSLAST(SZ2);
C3:=SS2>=2 AND SS2
{输出}
{全市场适用}
DRAWTEXT(GP AND PERIOD=5 AND YD1 AND COUNT(AMO>0,0)>5,0.992*L,'↖▲'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YD2 AND COUNT(AMO>0,0)>5,0.992*L,'↖2'),COLORB4B4B4;
{上证A股连续异动}
DRAWTEXT(GP AND PERIOD=5 AND YD3 AND CYB=0,0.992*L,'↖3'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YD4 AND INBLOCK('上证A股'),0.992*L,'↖4'),COLORWHITE;
DRAWTEXT(GP AND PERIOD=5 AND YD5 AND SHZB,0.992*L,'↖5'),COLORLIGRAY;
DRAWTEXT(GP AND PERIOD=5 AND YDX AND INBLOCK('上证A股'),0.992*L,'↖▲'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YDX2 AND INBLOCK('上证A股'),0.992*L,'↖2'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YDX3 AND INBLOCK('上证A股'),0.992*L,'↖3'),COLORB4B4B4;
{深证A股连续异动}
DRAWTEXT(GP AND PERIOD=5 AND CY3,0.992*L,'↖▲'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND CY4,0.992*L,'↖2'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YD4 AND SZZB AND DATE<1230410,0.992*L,'↖4'),COLORWHITE;
DRAWTEXT(GP AND PERIOD=5 AND YD5 AND SZZB AND DATE<1230410,0.992*L,'↖5'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YDX AND SZZB AND DATE<1230410,0.992*L,'↖▲'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YDX2 AND SZZB AND DATE<1230410,0.992*L,'↖2'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND YDX3 AND SZZB AND DATE<1230410,0.992*L,'↖3'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND SZZB4 AND SZZB AND DATE>=1230410,0.992*L,'↖4'),COLORWHITE;
DRAWTEXT(GP AND PERIOD=5 AND SZZB1 AND SZZB AND DATE>=1230410,0.992*L,'↖▲'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND SZZB2 AND SZZB AND DATE>=1230410,0.992*L,'↖2'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND SZZB3 AND SZZB AND DATE>=1230410,0.992*L,'↖3'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND SZ1 AND SZZB,0.992*L,'↖▲'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND SZ2 AND SZZB,0.992*L,'↖2'),COLORB4B4B4;
DRAWTEXT(GP AND PERIOD=5 AND SZ3 AND SZZB,0.992*L,'↖3'),COLORB4B4B4;
{10个交易日内涨幅偏离值大于100%,30个交易日内涨幅偏离值大于200%}
DRAWICON(GP AND PERIOD=5 AND Y1 AND SHZB AND DATE>=1230417,L,1);
DRAWICON(GP AND PERIOD=5 AND Y2 AND SHZB AND DATE>=1230524,L,38);
DRAWICON(GP AND PERIOD=5 AND Y1 AND KCB,L,1);
DRAWICON(GP AND PERIOD=5 AND Y2 AND KCB AND DATE>=1230101,L,38);
DRAWICON(GP AND PERIOD=5 AND CY101 AND CYB,L,1);
DRAWICON(GP AND PERIOD=5 AND CY102 AND CYB,L,1);
DRAWICON(GP AND PERIOD=5 AND CY201 AND CYB AND DATE>=1230101,L,38);
DRAWICON(GP AND PERIOD=5 AND CY202 AND CYB AND DATE>=1230101,L,38);
DRAWICON(GP AND PERIOD=5 AND Y1 AND SZZB AND EXISTR(YD4,9,1)=0 AND DATE>=1230417,L,1);
DRAWICON(GP AND PERIOD=5 AND Y2 AND SZZB AND EXISTR(X1,W2,1)=0 AND DATE>=1230524,L,38);