D1:=12;D2:=21;
C1:=26;C2:=34;
MM1:=IF(PERIOD=1,D2,IF(PERIOD=2,D2,IF(PERIOD=3,D2,IF(PERIOD=4,D1,
IF(PERIOD=5,D1,IF(PERIOD=6,D1,IF(PERIOD=7,D1,0)))))));
MM2:=IF(PERIOD=1,C2,IF(PERIOD=2,C2,IF(PERIOD=3,C2,IF(PERIOD=4,C1,
IF(PERIOD=5,C1,IF(PERIOD=6,C1,IF(PERIOD=7,C1,0)))))));
M1:=3;
DIFF:=EMA((EMA(CLOSE,MM1)-EMA(CLOSE,MM2))/EMA(CLOSE,MM2)*1000,M1);
DEA1:=EMA(DIFF,9);
MACD1:=(DIFF-DEA1)/5;
MACD:MACD1,COLORSTICK,COLORRED;
STICKLINE(MACD1<REF(MACD1,1)AND MACD1<0,0,MACD1,0,0),COLORGREEN;
STICKLINE(MACD1<REF(MACD1,1)AND MACD1>=0,0,MACD1,0,0),COLORFFD680;
STICKLINE(MACD1>REF(MACD1,1) AND MACD1<0,0,MACD1,0,0),COLORMAGENTA;
DIF:=(EMA(CLOSE,MM1)-EMA(CLOSE,MM2))/((EMA(CLOSE,MM1)+EMA(CLOSE,MM2))/2)*100;
DEA:=SMA(DIF,5,2);
KDIF:=3*(DIF-DEA);
KDEA:=SMA(KDIF,5,2);
KDEA1:=SMA(KDIF,8,2);
长DIF:KDEA,LINETHICK1;
长DEA:KDEA1,LINETHICK1,COLORFFFF00;
IF(长DEA<REF(长DEA,1),长DEA,DRAWNULL),COLORGREEN,LINETHICK1;