{主图}
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
T:=BARSLAST(CROSS(0,MACD));
TA:=BARSLAST(CROSS(MACD,0));
T2:=REF(T,TA+1)+TA+1;
L1:=LLV(L,T+1);
L2:=REF(L1,T+1);
L1T:=BARSLAST(L=L1);
M1:=REF(MACD,BARSLAST(L=L1));
M2:=REF(M1,T+1+T+1);
L2T:=BARSLAST(L=CONST(L2));
TJ:=(T2-TA)>=10 AND (TA-T)>=10;
TJ1:=L1<L2 AND M1>M2;
EXT:DRAWLINE(L2T=0,L,L1T=0 AND TJ AND TJ1 AND T>=10 AND L2T>20 ,L,0),COLORYELLOW;
DRAWTEXT(CROSS(EXT!=DRAWNULL,0.5),EXT*1.05,'底背离'),COLORYELLOW;
{幅图}
DIF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIF,9);
MACD:(DIF-DEA)*2,COLORSTICK;
T:=BARSLAST(CROSS(0,MACD));
TA:=BARSLAST(CROSS(MACD,0));
T2:=REF(T,TA+1)+TA+1;
L1:=LLV(L,T+1);
L2:=REF(L1,T+1);
L1T:=BARSLAST(L=L1);
M1:=REF(MACD,BARSLAST(L=L1));
M2:=REF(M1,T+1+T+1);
L2T:=BARSLAST(L=CONST(L2));
TJ:=(T2-TA)>=10 AND (TA-T)>=10;
TJ1:=L1<L2 AND M1>M2;
EXT:DRAWLINE(L2T=0,MACD,L1T=0 AND TJ AND TJ1 AND T>=10 AND L2T>20,MACD,0),DOTLINE,COLORMAGENTA;
DRAWTEXT(CROSS(EXT!=DRAWNULL,0.5),MACD,'底背离'),COLORMAGENTA;
{选股}
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
T:=BARSLAST(CROSS(0,MACD));
TA:=BARSLAST(CROSS(MACD,0));
T2:=REF(T,TA+1)+TA+1;
L1:=LLV(L,T+1);
L2:=REF(L1,T+1);
L1T:=BARSLAST(L=L1);
M1:=REF(MACD,BARSLAST(L=L1));
M2:=REF(M1,T+1+T+1);
L2T:=BARSLAST(L=CONST(L2));
TJ:=(T2-TA)>=10 AND (TA-T)>=10;
TJ1:=L1<L2 AND M1>M2;
XG:TJ AND TJ1 AND L1T=0 AND T>=10 AND L2T>20;