DIFF:EMA(CLOSE,12) - EMA(CLOSE,26),NOTEXT; DEA:EMA(DIFF,9),NOTEXT; MACD:2*(DIFF-DEA),NODRAW; STICKLINE1(MACD>=0,0,MACD,0.5,1),COLORRED; STICKLINE1(MACD<0,0,MACD,0.5,1),COLORCYAN; STICKLINE1(MACD>0&&MACD<REF(MACD,1)&&REF(MACD,1)>REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD<0&&MACD>REF(MACD,1)&&REF(MACD,1)<REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD>=0,0,MACD,0.5,1),COLORRED; STICKLINE1(MACD<0,0,MACD,0.5,1),COLORCYAN; STICKLINE1(MACD>0&&MACD<REF(MACD,1)&&REF(MACD,1)>REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD<0&&MACD>REF(MACD,1)&&REF(MACD,1)<REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD>=0,0,MACD,0.5,1),COLORRED; STICKLINE1(MACD<0,0,MACD,0.5,1),COLORCYAN; STICKLINE1(MACD>0&&MACD<REF(MACD,1)&&REF(MACD,1)>REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD<0&&MACD>REF(MACD,1)&&REF(MACD,1)<REF(MACD,2),0,MACD,1,1),COLORYELLOW; JC:=CROSS(DIFF,DEA); SC:=CROSSDOWN(DIFF,DEA); N1:=BARSLAST(JC)+1; N2:=BARSLAST(SC)+1; HH3:=VALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(H,N1));//上次MACD紅柱期間合約最大值 HH4:=VALUEWHEN(CROSSDOWN(DIFF,DEA),REF(HH3,1));//上上次MACD紅柱期間合約最大值 MHD:=VALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(MACD,N1));//上次MACD紅柱期間MACD最大值 MHD2:=VALUEWHEN(CROSSDOWN(DIFF,DEA),REF(MHD,1));//上上次MACD紅柱期間MACD最大值 LL3:=VALUEWHEN(CROSS(DIFF,DEA),LLV(L,N2));//上次MACD綠柱期間合約最小值 LL4:=VALUEWHEN(CROSS(DIFF,DEA),REF(LL3,1));//上上次MACD綠柱期間合約最小值 MLD:=VALUEWHEN(CROSS(DIFF,DEA),LLV(MACD,N2));//上次MACD綠柱期間MACD最小值 MLD2:=VALUEWHEN(CROSS(DIFF,DEA),REF(MLD,1));//上上次MACD綠柱期間MACD最小值 AA:=CROSSDOWN(DIFF,DEA)&&HH3>HH4&&MHD<MHD2;//頂背離 BB:=CROSS(DIFF,DEA)&&LL3<LL4&&MLD>MLD2;//底背離 DRAWTEXT(CROSS(AA=1,0.5),DIFF,'頂背'),VALIGN2,COLORCYAN; DRAWTEXT(CROSS(BB=1,0.5),DIFF,'底背'),VALIGN0,COLORMAGENTA; XN2:=SUMBARS(SC,2); XM2:=SUMBARS(JC,2); MACD3:=REF(LV(DIFF,N2),N1-1); MACD4:=REF(LV(DIFF,N2),XM2-1); MACD1:=REF(HV(DIFF,N1),N2-1); MACD2:=REF(HV(DIFF,N1),XN2-1); 頂背離:=CROSS(0,MACD) && HH3>HH4 && MACD1<MACD2 ; DRAWTEXT(頂背離,DIFF,'頂背'),VALIGN2,COLORCYAN; Q:=BACKSET(CROSS(0,MACD),HHVBARS(DIFF,N1)+1); QQ:=BACKSET(頂背離,SUMBARS(Q>REF(Q,1),2)); DRAWLINE1(QQ>REF(QQ,1),DIFF,Q>REF(Q,1),DIFF,0),COLORCYAN; 底背離:=CROSS(MACD,0) && LL3<LL4 && MACD3>MACD4; DRAWTEXT(底背離,DIFF,'底背'),VALIGN0,COLORMAGENTA; W:=BACKSET(CROSS(MACD,0),LLVBARS(DIFF,N2)+1); WW:=BACKSET(底背離,SUMBARS(W>REF(W,1),2)); DRAWLINE1(WW>REF(WW,1),DIFF,W>REF(W,1),DIFF,0),COLORMAGENTA; 快線:DIFF; DRAWCOLORLINE(快線>REF(快線,1),快線,RGB(255,0,128),RGB(0,128,255)); 慢線:DEA; DRAWCOLORLINE(慢線>REF(慢線,1),慢線,RGB(255,128,64),RGB(0,255,0)),LINETHICK2; 低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1; STICKLINE(低位金叉,0,0.08,6,0),COLORYELLOW; JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,0.04,6,0),COLORFF00FF; A1:=BARSLAST(REF(CROSS(DIFF,DEA),1)); 底背離1:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA); STICKLINE(底背離1,0,0.03,6,0),COLOR00FF00; DRAWLINE1(CROSS(BACKSET(底背離1,BARSLAST(A1=0)+1),0.5),DEA,底背離1,DEA,0),RGB(255,255,0),LINETHICK2; A22:=BARSLAST(REF(CROSS(DEA,DIFF),1)); 頂背離1:=REF(CLOSE,A22+1)<CLOSE && REF(DIFF,A22+1)>DIFF && CROSS(DEA,DIFF); STICKLINE(頂背離1,0,0.03,6,0),RGB(0,128,255); DRAWTEXT(頂背離1,DIFF,'頂背'),VALIGN2,COLORCYAN; DIFF1 : EMA(CLOSE,12) - EMA(CLOSE,26),NOTEXT,NODRAW; DEA1 : EMA(DIFF1,9),NOTEXT,NODRAW; MACD11:2*(DIFF-DEA),COLORSTICK,NOTEXT,NODRAW; DRAWICON(CROSS(MACD11,0),MACD,4); DRAWICON(CROSSDOWN(MACD1,0),MACD,5),VALIGN0;
DIFF:EMA(CLOSE,12)-EMA(CLOSE,27); DEA:EMA(DIFF,9); MACD:2*(DIFF-DEA), COLORSTICK,LINETHICK2; STICKLINE1(MACD>=0,0,MACD,0.5,1),COLORRED; STICKLINE1(MACD<0,0,MACD,0.5,1),COLORCYAN; STICKLINE1(MACD>0&&MACD<REF(MACD,1)&&REF(MACD,1)>REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD<0&&MACD>REF(MACD,1)&&REF(MACD,1)<REF(MACD,2),0,MACD,1,1),COLORYELLOW; 快線:DIFF; DRAWCOLORLINE(快線>REF(快線,1),快線,RGB(255,0,128),RGB(0,128,255)); 慢線:DEA; DRAWCOLORLINE(慢線>REF(慢線,1),慢線,RGB(255,128,64),RGB(0,255,0)),LINETHICK2; 低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1; STICKLINE(低位金叉,0,0.08,6,0),COLORYELLOW; DRAWTEXT(低位金叉,0.16,' 低位金叉'),COLORWHITE; JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,0.06,6,0),COLORFF00FF; DRAWTEXT(二次金叉,0.2,' 二次金叉'),COLORYELLOW; A1:=BARSLAST(REF(CROSS(DIFF,DEA),1)); 底背離:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA); STICKLINE(底背離,0,0.03,6,0),COLOR00FF00; DRAWLINE1(CROSS(BACKSET(底背離,BARSLAST(A1=0)+1),0.5),DEA,底背離,DEA,0),COLORRED,LINETHICK4; DRAWTEXT(底背離,0.12,' 底背離'),COLORFF00FF; A22:=BARSLAST(REF(CROSS(DEA,DIFF),1)); 頂背離:=REF(CLOSE,A22+1)<CLOSE && REF(DIFF,A22+1)>DIFF && CROSS(DEA,DIFF); STICKLINE(頂背離,0,0.03,6,0),RGB(0,128,255); DRAWTEXT(頂背離,-0.12,' 頂背離'),RGB(0,255,255); DIFF1 : EMA(CLOSE,12) - EMA(CLOSE,26),NOTEXT,NODRAW; DEA1 : EMA(DIFF1,9),NOTEXT,NODRAW; MACD1:2*(DIFF-DEA),COLORSTICK,NOTEXT,NODRAW; DRAWICON(CROSS(MACD1,0),MACD,4); DRAWICON(CROSSDOWN(MACD1,0),MACD,5),VALIGN0;
DIFF:EMA(CLOSE,12)-EMA(CLOSE,27); DEA:EMA(DIFF,9); MACD:2*(DIFF-DEA), COLORSTICK,LINETHICK2; STICKLINE1(MACD>=0,0,MACD,0.5,1),COLORRED; STICKLINE1(MACD<0,0,MACD,0.5,1),COLORCYAN; STICKLINE1(MACD>0&&MACD<REF(MACD,1)&&REF(MACD,1)>REF(MACD,2),0,MACD,1,1),COLORYELLOW; STICKLINE1(MACD<0&&MACD>REF(MACD,1)&&REF(MACD,1)<REF(MACD,2),0,MACD,1,1),COLORYELLOW; 快線:DIFF; DRAWCOLORLINE(快線>REF(快線,1),快線,RGB(255,0,128),RGB(0,128,255)); 慢線:DEA; DRAWCOLORLINE(慢線>REF(慢線,1),慢線,RGB(255,128,64),RGB(0,255,0)),LINETHICK2; 低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1; STICKLINE(低位金叉,0,0.08,6,0),COLORYELLOW; DRAWTEXT(低位金叉,0.16,' 低位金叉'),COLORWHITE; JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,0.06,6,0),COLORFF00FF; DRAWTEXT(二次金叉,0.2,' 二次金叉'),COLORYELLOW; A1:=BARSLAST(REF(CROSS(DIFF,DEA),1)); 底背離:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA); STICKLINE(底背離,0,0.03,6,0),COLOR00FF00; DRAWLINE1(CROSS(BACKSET(底背離,BARSLAST(A1=0)+1),0.5),DEA,底背離,DEA,0),COLORRED,LINETHICK4; DRAWTEXT(底背離,0.12,' 底背離'),COLORFF00FF; A22:=BARSLAST(REF(CROSS(DEA,DIFF),1)); 頂背離:=REF(CLOSE,A22+1)<CLOSE && REF(DIFF,A22+1)>DIFF && CROSS(DEA,DIFF); DRAWTEXT(頂背離,DEA,' 頂背離'),COLORGREEN;
|
|
來自: 一名津人 > 《文華MACD 指標》