N:=3;
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
KX:=BARSSINCE(CLOSE);
HHN:=CONST(HHV(DIFF,KX));
HLN:=CONST(LLV(DEA,KX));
RC1:=CONST((HHN+HLN)/2);
SS:=((HHN-HLN)/200);
MACD底部:=(-100*SS+RC1)+-(-100*SS+RC1),COLOR669999;
MACD顶部:=(100*SS+RC1)+-(-100*SS+RC1),COLORFF0033;
MACD中轴:=0+-(-100*SS+RC1);
DIFF修正:=DIFF+-(-100*SS+RC1),COLOR008080;
DEA修正:=DEA+-(-100*SS+RC1),COLOR00FF00;
MACD修正1:=2*(DIFF修正-DEA修正)+MACD中轴,COLOR0000BB,NODRAW;
MACD修正2:= EMA(MACD修正1,3);
MACD超跌:=CONST(LLV(MACD修正1,KX));
MACD超跌线:=IF(MACD超跌< MACD底部,MACD超跌,MACD底部);
顶部:=MACD顶部+-MACD超跌线;
天际:=顶部*0.809;
中轴:=MACD中轴+-MACD超跌线;
海面:=顶部*0.191;
底部:=MACD底部;
DIF55:=(EMA(CLOSE,55)-EMA(CLOSE,119))*0.55;
DEA55:=(EMA(DIF55,41));
DRAWBAND(DEA55,RGB(0,255,0),DIF55,RGB(255,0,255));
DIF60:=EMA(CLOSE,12/2)-EMA(CLOSE,26/2);
DEA60:=EMA(DIF60,9/2);
DRAWBAND(DEA60,RGB(0,255,255),DIF60,RGB(255,255,0));
AA:=REF(DIF60,N)=HHV(DIF60,2*N+1);
BB:= (AA,N+1);
CC:=FILTER(BB,N) AND DIF60=HHV(DIF60,N+1);
A11:=BARSLAST(REF(CC,1));
顶背离:=REF(CLOSE,A11+1)< CLOSE AND REF(DIF60,A11+1)>DIF60 AND CC;
MACD多头:DIFF修正+-MACD超跌线,COLOR339999;
空头:DEA修正+-MACD超跌线,COLOR00FF00;
量能柱:2*(MACD多头-空头)+中轴,COLOR0000BB,NODRAW;
超前DEA:=(EMA(MACD多头,7));
超前MACD:=2*(MACD多头-超前DEA)+中轴;
MACD多空趋势:DRAWBAND(MACD多头,RGB(204,51,51),空头,RGB(0,130,244));
MACD多头重画:DRAWBAND(MACD多头,RGB(153,153,51),MACD多头,RGB(153,153,51));
MACD空头重画:DRAWBAND(空头,RGB(0,224,224),空头,RGB(0,224,224));
MACD红柱1:STICKLINE(量能柱>=中轴,量能柱,中轴,1.5,0),COLOR2E0022{COLOR000077};
MACD红柱2:STICKLINE(量能柱>=中轴,量能柱,中轴,1.1,0),COLOR372635{COLOR809A3C}{COLOR000088};
MACD红柱3:STICKLINE(量能柱>=中轴,量能柱,中轴,0.6,0),COLORFF00FF{COLOR000099};
MACD红柱4:STICKLINE(量能柱>=中轴,量能柱,中轴,0.15,0),COLORFF00FF{COLOR0000AA};
MACD兰柱1:STICKLINE(量能柱<=中轴,量能柱,中轴,1.5,0),COLOR2E0022{COLOR808040}{COLORAA6633};
MACD兰柱2:STICKLINE(量能柱<=中轴,量能柱,中轴,1.1,0),COLOR372635{COLOR809A3C}{COLORBB7744};
MACD兰柱3:STICKLINE(量能柱<=中轴,量能柱,中轴,0.6,0),COLORGREEN{COLORCC8855};
MACD兰柱4:STICKLINE(量能柱<=中轴,量能柱,中轴,0.15,0),COLORGREEN{COLORDD9966};