根据DDX资金流入和流出,在主图上画出资金进出的矩形,黄色矩形资金流入,青色矩形资金流出,标示了周月的开盘价,表示了每日相对量。
参数:
M1,资金平均的短周期
M2,资金平均的长周期
S,是否标注突破30日价格和量的文字
N1,价格和量突破的周期
P,应对上市日期读错的情况,作废了
源码:
上市日期:(FINANCE(42)+1),COLORLIGRAY,NODRAW;
流通市值:(FINANCE(40)/100000000),NODRAW,COLORRED;
VAR1:=VOL/((HIGH-LOW)*2-ABS(CLOSE-OPEN));
买:=IF(CLOSE>OPEN,VAR1*(HIGH-LOW),IF(CLOSE<OPEN,VAR1*((HIGH-OPEN)+(CLOSE-LOW)),VOL/2)) ;
卖:=IF(CLOSE>OPEN,0-VAR1*((HIGH-CLOSE)+(OPEN-LOW)),IF(CLOSE<OPEN,0-VAR1*(HIGH-LOW),0-VOL/2));
买卖%:=ABS(买/卖);
买M5:=MA(买,M1),NODRAW;
卖M5:=MA(卖,M1),NODRAW;
MAVOL1:=MA(VOL,M1);
MAVOL2:=MA(VOL,M2);
UP:=IF(P>0,CROSS(买M5,-卖M5),CROSS(MAVOL1,MAVOL2)),NODRAW;
DOWN:=IF(P>0,CROSS(-卖M5,买M5),CROSS(MAVOL2,MAVOL1)),NODRAW;
{UP:=CROSS(买M5,-卖M5),NODRAW;
DOWN:=CROSS(-卖M5,买M5),NODRAW;}
UPL:=BARSLAST(UP),NODRAW;
UPE:=BARSNEXT(UP),NODRAW;
DOWNL:=BARSLAST(DOWN),NODRAW;
DOWNE:=BARSNEXT(DOWN),NODRAW;
UO:=REF(O,UPL),NODRAW;
MO:=REFX(C,DOWNE-1),NODRAW;
DC:=REFX(C,UPE-1),NODRAW;
DRAWSL(UP,O,0,DOWNE-1,0),COLORYELLOW;{上升矩形}
DRAWSL(UP,MO,0,DOWNE-1,0),COLORYELLOW;
STICKLINE(UP,O,MO,0,0),COLORYELLOW;
STICKLINE(DOWNE==1,C,UO,0,0),COLORYELLOW;
DRAWSL(DOWN,DC,0,UPE-1,0),COLORGREEN;{下降矩形}
DRAWSL(DOWN,O,0,UPE-1,0),COLORGREEN;
STICKLINE(DOWN,O,DC,0,0),COLORGREEN;
STICKLINE(UPE==1,C,REF(O,DOWNL),0,0),COLORGREEN;
{====================================}
{突破N1=30日量前高}
{N1:=30;}
K1:=REF(C,1)=DYNAINFO(3) AND O=DYNAINFO(4) AND C=DYNAINFO(7) AND H=DYNAINFO(5) AND L=DYNAINFO(6);
K2:=BARSLAST(V=HHV(V,N1));
K3:=BACKSET(K1,K2+1);
DRAWSL(K2=0 AND K3=1,H,0,2,0),COLORWHITE,LINETHICK2;
收:C,NODRAW;
{DRAWTEXT(S=1&&K2=0&&K3=1,H*1.02,'破N1日最高量的最高价'),COLORGREEN;}
DRAWTEXT(S=1&&K2=0&&K3=1,H*0.97,'V'),COLORWHITE,LINETHICK2;
{突破N1=30日价格前高}
TJG:=C==HHV(H,N1) AND REF(C,1)<HHV(H,N1);
K4:=BARSLAST(TJG);
K5:=BACKSET(K1,K4+1);
DRAWSL(K4=0 AND K5=1,C,0,2,0),COLORWHITE,LINETHICK2;
DRAWTEXT(S=1 AND K4=0 AND K5=1,C*0.97,'P'),COLORWHITE;
{标示周月开盘价}
YN:=MOD(YEAR,4)==0 AND MOD(YEAR,100)!=0,NODRAW;
DN:=IF(MONTH==1 OR MONTH==3 OR MONTH==5 OR MONTH==7 OR MONTH==8 OR MONTH==10 OR MONTH==12,31,IF(MONTH==4 OR MONTH==6 OR MONTH==9 OR MONTH==11,30,IF(MONTH==2,IF(YN,29,28),0))),NODRAW;
FD:=IF(DAY<REF(DAY,1),DAY,0),NODRAW;
{LD:=IF(DAY>REF(DAY,1) AND DAY>REFX(DAY,1),DAY,0),NODRAW;}
FW:=IF(WEEKDAY<REF(WEEKDAY,1) AND WEEKDAY!=0,WEEKDAY,0),NODRAW;
{LW:=IF(WEEKDAY>REF(WEEKDAY,1) AND WEEKDAY>REFX(WEEKDAY,1),WEEKDAY,0),NODRAW;}
DRAWSL(DAY==FD OR DAY==1,O,0,10,0),COLORMAGENTA,LINETHICK2;
{DRAWSL(DAY==LD OR DAY==DN,C,0,1,0),COLORRED,LINETHICK3,POINTDOT;}
DRAWSL(WEEKDAY==FW OR WEEKDAY==1,O,0,1,0),COLORWHITE,LINETHICK5,POINTDOT;
{DRAWSL(WEEKDAY==5,C,0,1,0),COLORBLUE,LINETHICK5,POINTDOT;}
{标示相对量}
P:=IF(上市日期>120,上市日期,120),NODRAW;
买卖差:=买+卖,NODRAW;
最大差:=HHV(买卖差,P),NODRAW;
最小差:=LLV(买卖差,P),NODRAW;
相对差:IF(买卖差>0,买卖差/最大差,-买卖差/最小差)*100,NODRAW;
涨幅:=(C-REF(C,1))/REF(C,1)*100,NODRAW;
量价比:=相对差/涨幅,NODRAW;
A:=MA(C,5),NODRAW;
最大量:=HHV(VOL,P),NODRAW;
相对量:VOL/最大量*100,NODRAW;
三日差:SUM(相对差,3),NODRAW;
三日量:SUM(相对量,3),NODRAW;
五日差:SUM(相对差,5),NODRAW;
五日量:SUM(相对量,5),NODRAW;
十日差:SUM(相对差,10),NODRAW;
十日量:SUM(相对量,10),NODRAW;
Y1:=L*0.99,NODRAW;
Y2:=H*1.04,NODRAW;
B:=INTPART(ABS(相对量/10)),NODRAW;
S:=IF(B==10,0,B),NODRAW;
DRAWNUMBER(涨幅>0 AND 量价比>0 AND B!=0,Y1,S),COLORRED;
DRAWNUMBER(涨幅<0 AND 量价比>0 AND B!=0,Y2,S),COLORCYAN;
DRAWNUMBER(量价比<0 AND C>A AND B!=0,Y1,S),COLORGREEN;
DRAWNUMBER(量价比<0 AND C<A AND B!=0,Y1,S),COLORYELLOW;
Y3:=L*0.95,NODRAW;
Y4:=H*1.07,NODRAW;
B1:=INTPART(ABS(相对差/10)),NODRAW;
S1:=IF(B1==10,0,B1),NODRAW;
DRAWNUMBER(涨幅>0 AND 量价比>0 AND B1!=0,Y3,S1),COLORLIRED;
DRAWNUMBER(涨幅<0 AND 量价比>0 AND B1!=0,Y4,S1),COLORLICYAN;
DRAWNUMBER(量价比<0 AND C>A AND B1!=0,Y3,S1),COLORLIGREEN;
DRAWNUMBER(量价比<0 AND C<A AND B1!=0,Y3,S1),COLORYELLOW;