学习了不少老师们的“量 换手率”的佳作受益匪浅。做一叠加“月 半月 周量及分时叠加日量 ”公式。
供朋友们参考。有心得体会请跟帖交流学习!!!
//叠加 月 半月 周量及分时叠加日量
input:月(0,0,1),半月(0,0,1),周(0,0,1),日(0,0,1);
TBS:=POW(10,ABS(LOG(MINDIFF)));
BY:=MONTH;YB:=BY-REF(BY,1)<>0 OR BARPOS=1;
w:=BARSLAST(YB),LINETHICK;
dg:=w=0 or ISLASTBAR;
wx:=0*C;
for P=datacount-1 downto lbound(dg) do
if dg[P] then
wx[P]:=0;
else
wx[P]:=wx[P+1]+1;
r:=BACKSET(ISLASTBAR,w+1)-ISLASTBAR;
wx:=refx(wx,1)+r,LINETHICK;
oo:=ref(o,w);
zq1:=BARSLAST(ref(wx,1)=0 or BARPOS=1)+1;//月天数
yt1:=if(zq1=1 and refx(zq1,2)=1,13,if(refx(zq1,1)=1 or zq1=1,7,14));
YEK:=ROUND(OO*TBS)/TBS;
YES:=ROUND(refx(c,wx)*TBS)/TBS;
f:=YES>YEK or (YES=YEK and YES>ref(YES,W));
j:=cross(w,wx);
AS:=月;
月量:=SUM(V,zq1),ColorFFff00,LINETHICK0;
月换手率:=SUM(vol/CAPITAL*100,ZQ1),linethick0,PRECISion2,colorffff00;
STICKLINE(YEK<YES AND AS,0,月量*0.25,YT1,0),COLOReeaaEE;
STICKLINE(YEK>YES AND AS,0,月量*0.25,YT1,0),Color6AA932;
R:=DAY;
RBY:=IF(R<=15,R,R-15);
TY:=RBY;TB:=DATEDIFF(REF(DATE,1),DATE)<>TY-REF(TY,1) OR BARPOS=1;
TW:=BARSLAST(TB),LINETHICK;
Tdg:=TW=0 or ISLASTBAR;
Twx:=0*c;
for P=datacount-1 downto lbound(Tdg) do
if Tdg[P] then
Twx[P]:=0;
else
Twx[P]:=Twx[P+1]+1;
TTr:=BACKSET(ISLASTBAR,Tw+1)-ISLASTBAR;
Twx:=refx(Twx,1)+TTr,LINETHICK;
TQ:=BARSLAST(ref(Twx,1)=0 or BARPOS=1)+1;//N天数
TTo:=ref(o,Tw);
YYK:=ROUND(TTO*TBS)/TBS;
YYS:=ROUND(refx(c,Twx)*TBS)/TBS;
YT:=if(TQ=1 and refx(TQ,2)=1,13,if(refx(TQ,1)=1 or TQ=1,7,14));
YYL:=SUM(V,TQ),ColorFFff00,LINETHICK0;
ss:=半月;
STICKLINE(YYK<=YYS and ss,0,YYL*0.30,YT,0),Color613076;//Color5261EB Color613076
STICKLINE(YYK>=YYS and ss,0,YYL*0.30,YT,0),ColorFA7D32;
BZ:=WEEKDAY;ZB:=DATEDIFF(REF(DATE,1),DATE)<>BZ-REF(BZ,1) OR BARPOS=1;
ZW:=BARSLAST(ZB),LINETHICK;
Zdg:=ZW=0 or ISLASTBAR;
Zwx:=0*c;
for P=datacount-1 downto lbound(Zdg) do
if Zdg[P] then
Zwx[P]:=0;
else
Zwx[P]:=Zwx[P+1]+1;
Zr:=BACKSET(ISLASTBAR,Zw+1)-ISLASTBAR;
Zwx:=refx(Zwx,1)+Zr,LINETHICK;
zq:=BARSLAST(ref(Zwx,1)=0 or BARPOS=1)+1; //星期天数
Zo:=ref(o,Zw);
ZZK:=ROUND(ZO*TBS)/TBS;
ZZS:=ROUND(refx(c,Zwx)*TBS)/TBS;
ZT:=if(zq=1 and refx(zq,2)=1,13,if(refx(zq,1)=1 or zq=1,7,14));
周量:=SUM(V,zq),ColorFFff00,LINETHICK0;
周换手率:=SUM(vol/CAPITAL*100,ZQ),ColorFFff00,LINETHICK0;
ss:=周;
STICKLINE(ZZK<ZZS and ss,0,周量*0.45,ZT,0),Color3547E8,LINEDOT;//Color3547E8//ColorB468FF
STICKLINE(ZZK>ZZS and ss,0,周量*0.45,ZT,0),ColorFDDD32,LINEDOT;
RRL:=DAY;
RRL:=RRL-REF(RRL,1)<>0 OR BARPOS=1;
Rw:=BARSLAST(RRL),LINETHICK;
Rdg:=Rw=0 or ISLASTBAR;
Rwx:=0*C;
for P=datacount-1 downto lbound(Rdg) do
if Rdg[P] then
Rwx[P]:=0;
else
Rwx[P]:=Rwx[P+1]+1;
Rr:=BACKSET(ISLASTBAR,Rw+1)-ISLASTBAR;
Rwx:=refx(Rwx,1)+Rr,LINETHICK;
Roo:=ref(o,Rw);
Rzq1:=BARSLAST(ref(Rwx,1)=0 or BARPOS=1)+1;//N天数
Ryt1:=if(Rzq1=1 and refx(Rzq1,2)=1,13,if(refx(Rzq1,1)=1 or Rzq1=1,7,14));
RRK:=ROUND(ROO*TBS)/TBS;
RRS:=ROUND(refx(c,Rwx)*TBS)/TBS;
AR:=日;
日量:SUM(V,Rzq1),ColorFFff00,LINETHICK0;
STICKLINE(RRK<=RRS AND AR,0,日量*0.5,RYT1,0),ColorD24A92,LINEDOT;//ColorD24A92 COLOReeaaEE
STICKLINE(RRK>=RRS AND AR,0,日量*0.5,RYT1,0),Color6AA932,LINEDOT;
//日量:V,ColorFFff00,LINETHICK0;
换手率:vol/CAPITAL*100,ColorFFff00,LINETHICK0;
半月量:=SUM(V,TQ),ColorFFff00,LINETHICK0;
半月换手率:=SUM(vol/CAPITAL*100,TQ),ColorFFff00,LINETHICK0;
TT2:=ISLASTBAR=1;
DRAWTEXTEX(TT2,0,371,1,'【创于2010.06.14 草根】'+''),ColorFFFFFF;
DRAWTEXTEX(TT2,0,4,1,'【一周期: '+NUMTOSTR(ZQ[SYSPARAM(1)],0)+''+'天 】'+''),Color00FFFF;
DRAWTEXTEX(TT2,0,125,1,'【周量: '+NUMTOSTR(周量[SYSPARAM(1)],0)+''+'】'+' 周换手率【'+NUMTOSTR(周换手率[SYSPARAM(1)],2)+'%】'),Color00FFFF;
DRAWTEXTEX(TT2,0,4,16,'【半月周期: '+NUMTOSTR(TQ[SYSPARAM(1)],0)+''+'天 】'+''),Color00FFFF;
DRAWTEXTEX(TT2,0,125,16,'【半月量: '+NUMTOSTR(半月量[SYSPARAM(1)],0)+''+'】'+''+' 半月换手率【'+NUMTOSTR(半月换手率[SYSPARAM(1)],2)+'%】'),Color00FFFF;
DRAWTEXTEX(TT2,0,4,31,'【月周期: '+NUMTOSTR(zQ1[SYSPARAM(1)],0)+''+'天 】'+''),Color00FFFF;
DRAWTEXTEX(TT2,0,125,31,'【月量: '+NUMTOSTR(月量[SYSPARAM(1)],0)+''+'】'+''+' 月换手率【'+NUMTOSTR(月换手率[SYSPARAM(1)],2)+'%】'),Color00FFFF;
input:n(5,0,100),na(13,0,100),nb(135,0,500);
量:=VOL,VOLSTICK;
HSL:=VOL/CAPITAL*100;
地量0_1:STICKLINE(HSL<1,0,量,0.1,0 ),coloreeeeee;
STICKLINE(HSL<1,0,量,5,0 ),colordddddd;
STICKLINE(HSL<1,0,量,3,0 ),coloreeeeee;
STICKLINE(HSL<1,0,量,1,0 ),colorffffff;
低靡1_2:STICKLINE(HSL>=1 and HSL<2,0,量,0.1,0 ),coloreeee00;
STICKLINE(HSL>=1 and HSL<2,0,量,5,0 ),coloraaaa00;
STICKLINE(HSL>=1 and HSL<2,0,量,3,0 ),colorcccc00;
STICKLINE(HSL>=1 and HSL<2,0,量,1,0 ),coloreeee00;
温和2_3:STICKLINE(HSL>=2 and HSL<3,0,量,0.1,0 ),Color0080BB;
STICKLINE(HSL>=2 and HSL<3,0,量,5,0 ),Color0040dd;
STICKLINE(HSL>=2 and HSL<3,0,量,3,0 ),Color0060ee;
STICKLINE(HSL>=2 and HSL<3,0,量,1,0 ),Color0080BB;
活跃3_5:STICKLINE(HSL>=3 and HSL<5,0,量,0.1,0 ),color00eeee;
STICKLINE(HSL>=3 and HSL<5,0,量,5,0 ),color00aaaa;
STICKLINE(HSL>=3 and HSL<5,0,量,3,0 ),color00cccc;
STICKLINE(HSL>=3 and HSL<5,0,量,1,0 ),color00eeee;
带量5_8:STICKLINE(HSL>=5 and HSL<8,0,量,0.1,0 ),coloree00ee;
STICKLINE(HSL>=5 and HSL<8,0,量,5,0 ),coloraa00aa;
STICKLINE(HSL>=5 and HSL<8,0,量,3,0 ),colorcc00cc;
STICKLINE(HSL>=5 and HSL<8,0,量,1,0 ),coloree00ee;
放量8_15:STICKLINE(HSL>=8 and HSL<15,0,量,0.1,0 ),Color0000FF;
STICKLINE(HSL>=8 and HSL<15,0,量,5,0 ),Color0000aa;
sTICKLINE(HSL>=8 and HSL<15,0,量,3,0 ),Color0000cc;
sTICKLINE(HSL>=8 and HSL<15,0,量,1,0 ),Color0000FF;
巨量15_25:STICKLINE(HSL>=15 and HSL<25,0,量,0.01,0 ),coloree0000;
STICKLINE(HSL>=15 and HSL<25,0,量,5,0 ),coloraa0000;
STICKLINE(HSL>=15 and HSL<25,0,量,3,0 ),colorcc0000;
STICKLINE(HSL>=15 and HSL<25,0,量,1,0 ),coloree0000;
怪异25_F:STICKLINE(HSL>=25,0,量,0.1,0),color00ff00;
STICKLINE(HSL>=25,0,量,5,0),color00aa00;
STICKLINE(HSL>=25,0,量,3,0),color00cc00;
STICKLINE(HSL>=25,0,量,1,0),color00ee00;
MA3:MA(量,n),COLORFFffff,linethick1;
MAd:MA(量,na),COLOR00ffff,linethick1;
MA90:MA(量,nb),color00ff00;
DRAWTEXT(ISLASTBAR=1 AND MAd>REF(MAd,1),MAd,' '+NUMTOSTR(na,0)+'↑'),COLOR00ffff,align0;
DRAWTEXT(ISLASTBAR=1 AND MAd<REF(MAd,1),MAd,' '+NUMTOSTR(na,0)+'↑'),Color00ffff,align0;
DRAWTEXT(BARSTATUS=2 AND MA3>REF(MA3,1),MA3,' '+NUMTOSTR(n,0)+'↑'),COLORFFffff,align1;
DRAWTEXT(BARSTATUS=2 AND MA3<REF(MA3,1),MA3,' '+NUMTOSTR(n,0)+'↓'),ColorFFffff,align1;
DRAWTEXT(w>0 and j and as,0,'月'),Color0435FB,ALIGN1,PXUP127;
DRAWNUMBER(w>0 and j and as,0,BY,0),Color0435FB,ALIGN2,PXUP127;
EXPLAIN(CLOSE,' &n |