SHORT:=26;
LONG:=12;
M:=9;
DIF:=((EMA(CLOSE,SHORT)-EMA(CLOSE,LONG)))*-1;
DEA:=EMA(DIF,M);
MACD:=2*(DIF-DEA);
A4:=BARSLAST(ref(cross(dif,dea),1));
B1:=ref(c,A4+1)>c and ref(dif,A4+1)<dif and cross(dif,dea);
DRAWTEXT(FILTER(B1>0,5),dif+0.2,'背离'),COLORyellow;
操盘:STICKLINE(MACD>=0 AND MACD>=REF(MACD,1),0,MACD,4,1),COLORRED{COLOR6058FF};
减仓:STICKLINE(MACD>=0 AND MACD< REF(MACD,1),0,MACD,4,0),COLORred{COLOR6058FF};
反弹:STICKLINE(MACD<0 AND MACD>=REF(MACD,1),0,MACD,4,1),COLORYELLOW{COLORFFFF00};
寻底:STICKLINE(MACD<0 AND MACD< REF(MACD,1),0,MACD,4,0),COLORFFFF00;
空仓:0,COLORWHITE;
if(dif<0,dif,0),coloryellow,linethick2;
if(dif<0,0,dif),colorred,linethick2;
if(dif<dea,dif,dea),COLORWHITE,linethick2;
if(dif>dea,dea,dea),COLORgreen{colorff00ff},linethick2;