公開平常用的變色MACD源碼:
DIF :EMA(CLOSE,12) - EMA(CLOSE,26);
DEA :EMA(DIF,9);
MACD:=(DIF-DEA)*2;
A1:=MACD>=REF(MACD,1)AND MACD>0;
A2:=MACD>=HHV(MACD,20) OR MACD>=HHV(MACD,30) AND MACD>0;
VAR1:=EMA(CLOSE,12)-EMA(CLOSE,26);
VAR2:=EMA(VAR1,9);
VAR3:=2*(VAR1-VAR2);
STICKLINE(MACD<REF(MACD,1) AND MACD>0,0,MACD,0.5.0,0),COLORYELLOW;
STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,0.5.0,0),COLORRED;
STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,0.5.0,0)COLORWHITE;
STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,0.5.0,0),COLORGREEN;
STICKLINE(A2 AND MACD>0,0,MACD,0.5.0,0),COLORMAGENTA;
零軸:0,COLORLIBLUE;
DRAWICON(CROSS(DIF,DEA),DEA*1,1);
DRAWICON(CROSS(DEA,DIF),DEA*1,2);
{DRAWICON(CROSS(DIF,0),0*0.95,11);};