通达信MACD指针副图
VAR1:=1;
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORRED,LINETHICK2;
DEA:EMA(DIFF,9),COLORGREEN;
MACD:(DIFF-DEA)*2*VAR1,COLORSTICK;
STICKLINE(MACD<0 AND MACD>REF(MACD,2),0,MACD,0,0),COLORGREEN;
STICKLINE(MACD<0 AND MACD<=REF(MACD,2),0,MACD,0.1,0),COLORCYAN;
STICKLINE(MACD>=0 AND MACD>REF(MACD,2),0,MACD,0.1,0),COLORRED;
STICKLINE(MACD>=0 AND MACD<=REF(MACD,2),0,MACD,0,0),COLORYELLOW;
STICKLINE(DIFF<0 AND CROSS(DIFF,DEA),DEA,0,0,0),COLORRED;
STICKLINE(DIFF>0 AND CROSS(DEA,DIFF),DEA,0,0,0),COLORGREEN;
STICKLINE(DIFF<0 AND CROSS(DIFF,DEA),DEA,0,0,0),COLORRED;
STICKLINE(DIFF>0 AND CROSS(DEA,DIFF),DEA,0,0,0),COLORGREEN;
DRAWTEXT(DIFF<0 AND CROSS(DIFF,DEA),DEA/2,4);
DRAWTEXT(DIFF>0 AND CROSS(DEA,DIFF),DEA/2,4);
IF(DIFF<REF(DIFF,1),DIFF,DRAWNULL),COLORYELLOW,LINETHICK2;
VAR2:=DIFF;
VAR3:=BARSLAST(CROSS(DEA,VAR2));
VAR4:=LLV(CLOSE,VAR3+1);
VAR5:=LLV(VAR2,VAR3+1);
VAR6:=REF(VAR4,VAR3+1);
VAR7:=REF(VAR5,VAR3+1);
VAR8:=REF(VAR6,VAR3+1);
VAR9:=REF(VAR7,VAR3+1);
VAR10:=MACD<0 AND (VAR4<VAR6 AND (VAR2>VAR7 AND (REF(MACD,1)<0 AND VAR2<=REF(VAR2,1))) OR (VAR4<VAR8 AND (VAR2>VAR9 AND (REF(MACD,1)<0 AND (VAR2<=REF(VAR7,1) AND VAR8<VAR6)))));
VAR11:=REF(VAR10,1) AND (VAR2<VAR7 AND VAR2<VAR9);
VAR12:=REF(VAR10,1) AND VAR2>REF(VAR2,1) AND REF(VAR2,1)<0;
DRAWTEXT(FILTER(VAR10,20),(VAR2+MACD)/1.5,5),COLORYELLOW;
DRAWTEXT(FILTER(VAR11,20),(VAR2+MACD)/1.5,6),COLORGREEN;
DRAWTEXT(FILTER(VAR12,20),(VAR2+MACD)/1.5,7),COLORMAGENTA;
VAR13:=BARSLAST(CROSS(VAR2,DEA));
VAR14:=HHV(CLOSE,VAR13+1);
VAR15:=REF(VAR14,VAR13+1);
VAR16:=REF(VAR15,VAR13+1);
VAR17:=HHV(VAR2,VAR13+1);
VAR18:=REF(VAR17,VAR13+1);
VAR19:=REF(VAR18,VAR13+1);
VAR20:=(MACD>0 AND (VAR14>VAR15 AND (VAR2<VAR18 AND (REF(MACD,1)>0 AND VAR2>=REF(VAR2,1))) OR (VAR14>VAR16 AND (VAR2<VAR19 AND (REF(MACD,1)>0 AND (VAR2>=REF(VAR7,1) AND VAR8>VAR6))))))*VAR1;
VAR21:=(REF(VAR20,1) AND (VAR2>VAR18 AND VAR2>VAR19))*VAR1;
VAR22:=REF(VAR20,1) AND VAR2<REF(VAR2,1) AND REF(VAR2,1)>0;
DRAWTEXT(FILTER(VAR20,20),(VAR2+MACD)/1.5,5),COLORYELLOW;
DRAWTEXT(FILTER(VAR21,20),(VAR2+MACD)/1.5,6),COLORGREEN;
DRAWTEXT(FILTER(VAR22,20),(VAR2+MACD)/1.5,7),COLORCYAN;
VAR23:=5;
VAR24:=MACD*VAR1;
VAR25:=VAR23;
VAR26:=REF(VAR24,VAR23)=HHV(VAR24,2*VAR23+1);
VAR27:=BACKSET(VAR26,VAR23+1);
VAR28:=FILTER(VAR27,VAR23) AND VAR24=HHV(VAR24,VAR23+1);
VAR29:=BARSLAST(VAR28);
VAR30:=IF(VAR28,CURRBARSCOUNT,0);
VAR31:=IF(VAR29,REF(VAR24,VAR29),VAR24);
VAR32:=IF(VAR29,REF(VAR30,VAR29),VAR30);
VAR33:=REF(VAR31,VAR29+1);
VAR34:=CONST(VAR32);
VAR35:=REF(VAR32,VAR29+1);
VAR36:=CONST(VAR35);
VAR37:=REF(VAR33,VAR29+1);
VAR38:=IF(CURRBARSCOUNT>VAR36,0,1);
VAR39:=DRAWLINE(CURRBARSCOUNT=VAR36,VAR24,CURRBARSCOUNT=VAR34,VAR24,1);
S2:DRAWLINE(CURRBARSCOUNT=VAR34,VAR24,ISLASTBAR,REF(VAR24,VAR34-1),1),DOTLINE,COLORCYAN;
XG:CROSS(MACD,S2),NODRAW;
DRAWICON(XG,MACD,34);
VAR40:=CROSS(MACD,VAR39);
DRAWICON(VAR40,0,1);
VAR41:=REF(VAR24,VAR25)=LLV(VAR24,2*VAR25+1);
VAR42:=BACKSET(VAR41,VAR25+1);
VAR43:=FILTER(VAR42,VAR25) AND VAR24=LLV(VAR24,VAR25+1);
VAR44:=BARSLAST(VAR43);
VAR45:=IF(VAR43,CURRBARSCOUNT,0);
VAR46:=IF(VAR44,REF(VAR24,VAR44),VAR24);
VAR47:=IF(VAR44,REF(VAR45,VAR44),VAR45);
VAR48:=CONST(VAR47);
VAR49:=REF(VAR46,VAR44+1);
VAR50:=REF(VAR47,VAR44+1);
VAR51:=CONST(VAR50);
VAR52:=DRAWLINE(CURRBARSCOUNT=VAR51,VAR24,CURRBARSCOUNT=VAR48,VAR24,1);
B2:DRAWLINE(CURRBARSCOUNT=VAR48,VAR24,ISLASTBAR,REF(VAR24,VAR48-1),1),DOTLINE,COLORMAGENTA;
DRAWICON(CROSS(B2,MACD),MACD,35);