KDJ+MACD主图
{KDJ+MACD立体主图原码(效果图见KDJ+MACD主图一)。80线条的红、蓝色,其中红色段表示K值向上,20线条的红、蓝色,其中红色段表示MACD零下绿住缩短部份和0以上MACD部份。}
{指标名称:KDJ+MACD主图}
DRAWGBK(CLOSE>0, COLORRGB(1,1841,3411),COLORRGB(1,1881,6532),3);
kx:=SYSPARAM(3)-SYSPARAM(2)+1;
kh:=hhv(high,kx);
kl:=llv(low,kx);
kmx:=kh[datacount];
kmn:=kl[datacount];
kbl:=(kmx+kmn)/2;
kgdc:=kmx-kmn;
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:SMA(RSV,3,1),LINETHICK0,COLORWHITE;
D:SMA(K,3,1),LINETHICK0,COLOR00DDDD;
J:3*K-2*D,LINETHICK0,COLORBB00BB;
KA:=hhv(K,kx);
DA:=hhv(D,kx);
JA:=hhv(J,kx);
KB:=llv(K,kx);
DB:=llv(D,kx);
JB:=llv(J,kx);
mxak:=max(KA[datacount],max(DA[datacount],JA[datacount]));
mnak:=min(KB[datacount],min(DB[datacount],JB[datacount]));
kdbl:=(mxak+mnak)/2;
kdgdc:=mxak-mnak;
KC:=(K-kdbl)*(kgdc/kdgdc)+kbl;
DC:=(D-kdbl)*(kgdc/kdgdc)+kbl;
JC:=(J-kdbl)*(kgdc/kdgdc)+kbl;
DRAWTEXT(ISLASTBAR,(100-kdbl)*(kgdc/kdgdc)+kbl+0.08,' 100'),color00ff00;
DRAWTEXT(ISLASTBAR,(80-kdbl)*(kgdc/kdgdc)+kbl+0.08,' 80'),colorffffcc;
DRAWTEXT(ISLASTBAR,(50-kdbl)*(kgdc/kdgdc)+kbl+0.08,' 50'),colorffffff;
DRAWTEXT(ISLASTBAR,(20-kdbl)*(kgdc/kdgdc)+kbl+0.08,' 20'),color00ffff;
DRAWTEXT(ISLASTBAR,(0-kdbl)*(kgdc/kdgdc)+kbl+0.08,' 0'),color0099ff;
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26),linethick0,COLOR0099FF;
DEA:EMA(DIFF,9),linethick0,COLOR00dddd;
MACD:2*(DIFF-DEA),linethick0,color00cc00;
MHF:=HHV(DIFF,KX);
MHD:=HHV(DEA,KX);
MHM:=HHV(MACD,KX);
MLF:=LLV(DIFF,KX);
MLD:=LLV(DEA,KX);
MLM:=LLV(MACD,KX);
hmax:=max(mhf[datacount],max(mhd[datacount],mhm[datacount]));
lmin:=min(mlf[datacount],min(mld[datacount],mlm[datacount]));
mbl:=(hmax+lmin)/100;
mgdc:=hmax-lmin;
KCA:=hhv(KC,kx);
DCA:=hhv(DC,kx);
JCA:=hhv(JC,kx);
KCB:=llv(KC,kx);
DCB:=llv(DC,kx);
JCB:=llv(JC,kx);
mxakc:=max(KCA[datacount],max(DCA[datacount],JCA[datacount]));
mnakc:=min(KCB[datacount],min(DCB[datacount],JCB[datacount]));
kcbl:=(mxakc+mnakc)/2;
kcgdc:=mxakc-mnakc;
QD:=(0-mbl)*(kcgdc/mgdc)+kcbl;
DIFFA:=(DIFF-mbl)*(kcgdc/mgdc)+kcbl;
DEAA:=(DEA-mbl)*(kcgdc/mgdc)+kcbl;
MACDA:=(MACD-mbl)*(kcgdc/mgdc)+kcbl;
CDA:=if(MACD<ref(MACD,1) and MACD>0,1,0);
CDB:=IF(MACD>=ref(MACD,1) and MACD>=0,1,0);
CDC:=IF(MACD>ref(MACD,1) and MACD<0,1,0);
CDD:=IF(MACD<=ref(MACD,1) and MACD<=0,1,0);
STICKLINE(CDA,QD,macda,8,0),COLOR00AADD;{黄s段}
STICKLINE(CDA,QD,macda,6.6,0),COLOR00AADD;
STICKLINE(CDA,QD,macda,4.4,0),COLOR00BBDD;
STICKLINE(CDA,QD,macda,3.3,0),COLOR00BBDD;
STICKLINE(CDA,QD,macda,2.2,0),COLOR00CCDD;
STICKLINE(CDA,QD,macda,1.1,0),COLOR00DDDD;
STICKLINE(CDB,QD,macda,8,0),COLORCC33DD; {红色段}
STICKLINE(CDB,QD,macda,6.6,0),COLORDD22DD;
STICKLINE(CDB,QD,macda,4.4,0),COLORBB44DD;
STICKLINE(CDB,QD,macda,3.3,0),COLORBB55DD;
STICKLINE(CDB,QD,macda,2.2,0),COLORAA66DD;
STICKLINE(CDB,QD,macda,1.1,0),COLORAA77DD;
STICKLINE(CDC,QD,macda,8,0),COLORAA00AA;{向上粉红}
STICKLINE(CDC,QD,macda,6.6,0),COLORAA00AA;
STICKLINE(CDC,QD,macda,4.4,0),COLORBB11AA;
STICKLINE(CDC,QD,macda,3.3,0),COLORAA22AA;
STICKLINE(CDC,QD,macda,2.2,0),COLORCC33AA;
STICKLINE(CDC,QD,macda,1.1,0),COLORDD44AA;
STICKLINE(CDD,QD,macda,8,0),COLORCC1111;
STICKLINE(CDD,QD,macda,6.6,0),COLORCC2211;
STICKLINE(CDD,QD,macda,4.4,0),COLORCC3311;
STICKLINE(CDD,QD,macda,3.3,0),COLORCC4411;
STICKLINE(CDD,QD,macda,2.2,0),COLORCC5511;
STICKLINE(CDD,QD,macda,1.1,0),COLORCC6611;
DRAWTEXT(ISLASTBAR,QD,' 0'),color00aaaa;
rsv1:=(hhv(high,9.8)-close)/(hhv(high,9.8)-llv(low,9.8))*101;
kk:=sma(rsv1,3,1);
dd:=sma(kk,3,1);
jj:=3*kk-2*dd;
买卖:=if(jj>=100,100,if(jj<=0,0,jj));
低买:if(买卖=100,((0-kdbl)*(kgdc/kdgdc)+kbl)*0.98,(0-kdbl)*(kgdc/kdgdc)+kbl),COLOR00CCCC;
高卖:if(买卖=0,(90-kdbl)*(kgdc/kdgdc)+kbl,(100-kdbl)*(kgdc/kdgdc)+kbl),COLOR00CCAA;
KX1:=CLOSE>=OPEN or close>ref(close,1);
STICKLINE(KX1,C,O,7,0),COLOR0011aa;
STICKLINE(KX1,C,O,5,0),COLOR0022aa ;
STICKLINE(KX1,C,O,3,0),COLOR0033aa ;
STICKLINE(KX1,C,O,1,0),COLOR0044aa;
STICKLINE(KX1,H,L,0,0),COLOR0000dd;
KX2:=CLOSE<OPEN;{ or close<ref(close,1);}
STICKLINE(kx2,C,O,7,0),Color7B7b00;
STICKLINE(kx2,C,O,5,0),Color909000;
STICKLINE(kx2,C,O,3,0),ColorA8a800;
STICKLINE(kx2,C,O,1,0),COLORcece00;
STICKLINE(kx2,H,L,0,0),COLORffff00;
PARTLINE(KC,KC),COLORWHITE, linethick2;
PARTLINE(DC,DC),COLOR00DDDD,linethick2;
PARTLINE(JC>0 OR JC<0,JC),COLORBB00BB,linethick2;
PARTLINE(DIFF>0 or DIFF<0,DIFFA),POINTDOT,COLOR0099EE;
PARTLINE(DEA>0 or DEA<0,DEAA),POINTDOT,colorDDAAAA;
PARTLINE(K>=ref(K,1),(80-kdbl)*(kgdc/kdgdc)+kbl),COLORaa11bb,POINTDOT;
PARTLINE(K<ref(K,1),(80-kdbl)*(kgdc/kdgdc)+kbl),COLOR00bb00,POINTDOT;
PARTLINE(close,(50-kdbl)*(kgdc/kdgdc)+kbl),COLOR00BBBB,POINTDOT;
PARTLINE(CDB or CDC or CDA and diff/dea>=ref(diff/dea,1),(20-kdbl)*(kgdc/kdgdc)+kbl),COLORAA11BB,POINTDOT;
PARTLINE(CDD or CDA and diff/dea<ref(diff/dea,1),(20-kdbl)*(kgdc/kdgdc)+kbl),COLOR00bb00,POINTDOT; |