MACD2:=2*(MACD.DIF-MACD.DEA); STICKLINE(MACD2>=0 AND MACD2>REF(MACD2,1),0,MACD2,1.2,0),COLOR0000A5; STICKLINE(MACD2>=0 AND MACD2<REF(MACD2,1),0,MACD2,1.2,0),COLORAA7800; STICKLINE(MACD2<0 AND MACD2<REF(MACD2,1),0,MACD2,1.2,0),COLOR00A500; STICKLINE(MACD2<0 AND MACD2>REF(MACD2,1),0,MACD2,1.2,0),COLORA500A5; DIF:EMA(CLOSE,12)-EMA(CLOSE,26); DEA:EMA(DIF,9); MACD:(DIF-DEA)*2,NODRAW; {MACD日線二次金叉} JCCOUNT:=COUNT(CROSS(DIF,DEA),BARSLAST(DEA>=0)); 二次金叉:=CROSS(DIF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; DRAWTEXT(二次金叉,DEA*1.25,'零下二金'),COLORWHITE; {MACD日線底背離} A1:=BARSLAST(REF(CROSS(DIF,DEA),1)); 底背離:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA); DRAWTEXT(底背離,DIF*0.5,'日底背'),COLORRED; {日底背畫線:DRAWLINE(A1=0,DEA,底背離,DEA,0),COLORRED,DOTLINE;} {MACD日線頂背離} A2:=BARSLAST(REF(CROSS(DEA,DIF),1)); 頂背離:=REF(CLOSE,A2+1)<CLOSE AND REF(DIF,A2+1)>DIF AND CROSS(DEA,DIF); DRAWTEXT(頂背離,DIF*1.12,'日頂背'),COLORGREEN; {日頂背畫線:DRAWLINE(A2=0,DEA,頂背離,DEA,0),COLORGREEN,DOTLINE;} {MACD_KDJ的金叉共振} {DIF:EMA(CLOSE,12)-EMA(CLOSE,26);DEA:EMA(DIF,9);} RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9)); K:=SMA(RSV,9,3),NODRAW; D:=SMA(K,9,3),NODRAW; J:=3*K-2*D,NODRAW; M&K金共:=CROSS(DIF,DEA) AND CROSS(K,D) AND CROSS(J,D); DRAWTEXT(M&K金共,DEA*1.12,'金叉共振'),COLORYELLOW; {MACD柱背離} MACD高:=HHV(MACD,5); C1:=BARSLAST(REF(CROSS(DEA,DIF),1)); E:=REF(C,C1+1)>C AND DEA>0 AND REF(MACD高,C1+1)<MACD高 AND CROSS(DEA,DIF) ; DRAWTEXT(E>0,-0.5,'柱頂背'),COLORCYAN; F:=REF(C,A1+1)>C AND DEA<0 AND REF(MACD高,A1+1)<MACD高 AND CROSS(DIF,DEA); DRAWTEXT(F>0,0.5,'柱底背'),COLORLIRED; {MACD積背離} JC:= DEA-DIF; 綠柱面積:=IF(MACD<0,SUM(MACD,BARSLAST(JC<0)),0); 紅柱面積:=IF(MACD>0,SUM(MACD,BARSLAST(JC>0)),0); 本次最低價(jià):=LLV(L,BARSLAST(JC<0)); 本次最高價(jià):=HHV(H,BARSLAST(JC>0)); X1:=IF (MACD<0,BARSLAST(CROSS(DIF,DEA)),0); 前次綠柱面積:=REF(綠柱面積,X1+1); 前次最低價(jià):=REF(本次最低價(jià),X1+1); Y1:=IF((綠柱面積<0 AND ABS(綠柱面積)<ABS(前次綠柱面積) AND 本次最低價(jià)<前次最低價(jià) ),1,0); RS1:= MACD<0 AND REF(MACD,1)<0 AND C<前次最低價(jià) AND ABS(綠柱面積)<ABS(前次綠柱面積) AND ABS(MACD)<ABS(REF(MACD,1)); 底背馳:= IF (CROSS(DIF,DEA),REF(Y1,1),0); DRAWTEXT(底背馳,DEA*0.8,'積底背'),COLORFF80FF; X2:=IF (MACD>0,BARSLAST(CROSS(DEA,DIF)),0); 前次紅柱面積:=REF(紅柱面積,X2+1); 前次最高價(jià):=REF(本次最高價(jià),X2+1); Y2:=IF((紅柱面積>0 AND 紅柱面積<前次紅柱面積 AND 本次最高價(jià)>前次最高價(jià) ),1,0); RS2:= MACD>0 AND REF(MACD,1)>0 AND C>前次最高價(jià) AND ABS(紅柱面積)<ABS(前次紅柱面積) AND ABS(MACD)<ABS(REF(MACD,1)); 頂背馳:= IF (CROSS(DEA,DIF),REF(Y2,1),0); DRAWTEXT(頂背馳,DEA*0.8,'積頂背'),COLORCYAN;
{ 選股公式:
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26); DEA:=EMA(DIF,9); MACD:=(DIF-DEA)*2; A1:=BARSLAST(REF(CROSS(DIF,DEA),1)); 底背離:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA); MACD高:=HHV(MACD,5); F:=REF(C,A1+1)>C AND DEA<0 AND REF(MACD高,A1+1)<MACD高 AND CROSS(DIF,DEA); 柱底背:=F>0; JC:= DEA-DIF; 綠柱面積:=IF(MACD<0,SUM(MACD,BARSLAST(JC<0)),0); 紅柱面積:=IF(MACD>0,SUM(MACD,BARSLAST(JC>0)),0); 本次最低價(jià):=LLV(L,BARSLAST(JC<0)); 本次最高價(jià):=HHV(H,BARSLAST(JC>0)); X1:=IF (MACD<0,BARSLAST(CROSS(DIF,DEA)),0); 前次綠柱面積:=REF(綠柱面積,X1+1); 前次最低價(jià):=REF(本次最低價(jià),X1+1); Y1:=IF((綠柱面積<0 AND ABS(綠柱面積)<ABS(前次綠柱面積) AND 本次最低價(jià)<前次最低價(jià) ),1,0); RS1:= MACD<0 AND REF(MACD,1)<0 AND C<前次最低價(jià) AND ABS(綠柱面積)<ABS(前次綠柱面積) AND ABS(MACD)<ABS(REF(MACD,1)); 積底背:= IF (CROSS(DIF,DEA),REF(Y1,1),0); 三背離:底背離 AND 柱底背 AND 積底背; }
|