TAG:MACD

 网友求助:

nput:p(12,1,100),s(26,1,100),m(9,1,50),N(0,0,1);
MACD:="MACD.MACD#WEEK";

RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26),linethick0,COLOR0099FF;
DEA :EMA(DIFF,9),linethick0,COLORD89837;
MACD:2*(DIFF-DEA),COLORFF9999,linethick0;
KX:=250;
KH:=HHV(K,KX);
DH:=HHV(D,KX);
JH:=HHV(J,KX);
KL:=LLV(K,KX);
DL:=LLV(D,KX);
JL:=LLV(J,KX);
HKMAX:=MAX(KH,MAX(DH,JH));
LKMIN:=MIN(KL,MIN(DL,JL));
KHLB:=(HKMAX+LKMIN)/2;
KHLC:=HKMAX-LKMIN;
MHF:=HHV(DIFF,KX);
MHD:=HHV(DEA,KX);
MHM:=HHV(MACD,KX);
周MHM:=HHV(周MACD,KX);
MLF:=LLV(DIFF,KX);
MLD:=LLV(DEA,KX);
MLM:=LLV(MACD,KX);
周MLM:=LLV(周MACD,KX);
HMAX:=MAX(MHF,MAX(MHD,MHM));
周HMAX:=MAX(MHF,MAX(MHD,周MHM));
LMIN:=MIN(MLF,MIN(MLD,MLM));
周LMIN:=MIN(MLF,MIN(MLD,周MLM));
FHLB:=(HMAX-LMIN)/100;
周FHLB:=(周HMAX-周LMIN)/100;
FHLC:=HMAX-LMIN;
周FHLC:=周HMAX-周LMIN;
SH:=(0-FHLB)*(KHLC/FHLC)+KHLB;
周SH:=(0-周FHLB)*(KHLC/周FHLC)+KHLB;
DIFFA:((DIFF-FHLB)*(KHLC/FHLC)+KHLB),LINETHICK1;
DEAA:(DEA-FHLB)*(KHLC/FHLC)+KHLB,Color0AD8F5,LINETHICK1,LAYER0;
MACDA:(macd-FHLB)*(KHLC/FHLC)+KHLB,COLORRED,LINETHICK0;

周MACDA:=(周MACD-周FHLB)*(KHLC/周FHLC)+KHLB;

CDA:=MACD<ref(MACD,1) and MACD>0;
周CDA:=周MACD>0 AND DATATYPE=8;
CDB:=MACD>=ref(MACD,1) and MACD>0;
周CDB:=周MACD<0 AND DATATYPE=8;
CDC:=MACD>ref(MACD,1) and MACD<0;
CDD:=MACD<=ref(MACD,1) and MACD<0;
STICKLINE(周CDA,周SH,周macda,11,0),COLOR1E003C;
STICKLINE(周CDB,周SH,周macda,11,0),COLOR4B1E00;
STICKLINE(CDA,SH,macda,3.3,0),COLORCE00CE;
STICKLINE(CDB,SH,macda,3.3,0),COLOR0000CA;
STICKLINE(CDC,SH,macda,3.3,0),COLOR128C96;
STICKLINE(CDD,SH,macda,3.3,0),COLOR646400;
PARTLINE(DIFFA,DIFF>0,RGB(255,153,153),DIFF<0,RGB(255,153,153));
PARTLINE(DEAA,DEA>0,RGB(65,105,225),DEA<0,RGB(65,105,225));


ES:=IF(N=0,REF(EMA(C,S),1),EMA(C,S));
EP:=IF(N=0,REF(EMA(C,P),1),EMA(C,P));
DI:=IF(N=0,REF(DIFF,1),DIFF);
零度价:=((P+1)*(S-1)*ES-(S+1)*(P-1)*EP)/(2*(S+1)-2*(P+1));
IF N=0 AND REF(DIFF,1)<0 and barstatus=2 THEN BEGIN DRAWTEXTREL(5,0,'DIFF上穿零度:'+NUMTOSTRN(零度价,2)+'元'),COLOR0BC7FD;END;
IF N=1 AND DIFF<0 and barstatus=2 THEN BEGIN DRAWTEXTREL(5,0,'DIFF上穿零度:'+NUMTOSTRN(零度价,2)+'元'),COLOR0BC7FD;END;
IF N=0 AND REF(DIFF,1)>0 and barstatus=2 THEN BEGIN DRAWTEXTREL(5,0,'DIFF下穿零度:'+NUMTOSTRN(零度价,2)+'元'),COLORC08000;END;
IF N=1 AND DIFF>0 and barstatus=2 THEN BEGIN DRAWTEXTREL(5,0,'DIFF下穿零度:'+NUMTOSTRN(零度价,2)+'元'),COLORC08000;END;
拐点价:=((P-1)*EP/(P+1)-(S-1)*ES/(S+1)-DI)*(S+1)*(P+1)/(2*(P+1)-2*(S+1));
IF N=0 AND REF(DIFF,1)<REF(DIFF,2) and barstatus=2 THEN BEGIN DRAWTEXTREL(230,0,'DIFF向上拐点:'+NUMTOSTRN(拐点价,2)+'元'),COLOR0BC7FD;END;
IF N=1 AND DIFF<REF(DIFF,1) and barstatus=2 THEN BEGIN DRAWTEXTREL(230,0,'DIFF向上拐点:'+NUMTOSTRN(拐点价,2)+'元'),COLOR0BC7FD;END;
IF N=0 AND REF(DIFF,1)>REF(DIFF,2) and barstatus=2 THEN BEGIN DRAWTEXTREL(230,0,'DIFF向下拐点:'+NUMTOSTRN(拐点价,2)+'元'),COLORC08000;END;
IF N=1 AND DIFF>REF(DIFF,1) and barstatus=2 THEN BEGIN DRAWTEXTREL(230,0,'DIFF向下拐点:'+NUMTOSTRN(拐点价,2)+'元'),COLORC08000;END;

主升 : DIFFA>47 AND DIFFA>DEAA,COLOR0000FF,POINTDOT,LINETHICK0;
FILLRGN(DIFFA,DEAA,主升,RGB(200,0,0)),LAYER0;;
PARTLINE(DIFFA,DIFFA>REF(DIFFA,1)AND REF(DIFFA,1)>0,RGB(255,0,0),DIFFA<REF(DIFFA,1),
RGB(0,200,250),DIFFA>REF(DIFFA,1)AND REF(DIFFA,1)<0,RGB(255,0,255)),LAYER0;;


RSV1:=(CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100;
K1:=SMA(RSV1,5,1);
D1:=SMA(K1,5,1);
J1:=3*K1-2*D1;
AA1:=EMA(J1,5);
AA2:=REF(AA1,1);
STICKLINE(AA1>AA2,AA1,AA2,8,0),COLOR0055AA,POINTDOT;
STICKLINE(AA1>AA2,AA1,AA2,5,0),COLOR0077CC,POINTDOT;
STICKLINE(AA1>AA2,AA1,AA2,3,0),COLOR0099DD,POINTDOT;
STICKLINE(AA1>AA2,AA1,AA2,1,0),Color01BEE7,POINTDOT;
STICKLINE(AA1<=AA2,AA1,AA2,8,0),COLOR006600,POINTDOT;
STICKLINE(AA1<=AA2,AA1,AA2,5,0),COLOR009900,POINTDOT;
STICKLINE(AA1<=AA2,AA1,AA2,3,0),COLOR00BB00,POINTDOT;
STICKLINE(AA1<=AA2,AA1,AA2,1,0),COLOR00CC00,POINTDOT;
RSV2:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K2:=SMA(RSV2,3,1);
D2:=SMA(K2,3,1);
J2:=3*K2-2*D2;
BB1:=EMA(J2,5);
BB2:=REF(BB1,1);
STICKLINE(BB1>BB2,BB1,BB2,7,0),COLOR000045,POINTDOT;
STICKLINE(BB1>BB2,BB1,BB2,5,0),COLOR000085,POINTDOT;
STICKLINE(BB1>BB2,BB1,BB2,3,0),COLOR0000C5,POINTDOT;
STICKLINE(BB1>BB2,BB1,BB2,1,0),COLOR0000E5,POINTDOT;
STICKLINE(BB1<=BB2,BB1,BB2,7,0),COLOR353500,POINTDOT;
STICKLINE(BB1<=BB2,BB1,BB2,5,0),COLOR555500,POINTDOT;
STICKLINE(BB1<=BB2,BB1,BB2,3,0),COLOR757500,POINTDOT;
STICKLINE(BB1<=BB2,BB1,BB2,1,0),COLOR858500,POINTDOT;

 

 

解答如下: