DIFF : EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA : EMA(DIFF,M);
MACD : 2*(DIFF-DEA), COLORSTICK;
0,dotline,colorwhite;
N1:=last(MACD<0);{绿柱天数}
N2:=REF(last(MACD>0),N1);{绿柱前红柱天数}
N3:=REF(last(MACD<0),N2+N1);{红柱前绿柱天数}
MINMD0:=REF(LLV(MACD,N3+N2),N1);
MINDIFFF:=REF(LLV(DIFF,N3+N2),N1);
绿柱缩短:=MACD<0 AND MACD>REF(MACD,1) AND REF(MACD,1)<REF(MACD,2);
底背离:绿柱缩短 and REF(MACD,1)>MINMD0 and LLV(L,N1)<REF(LLV(L,N2+N3),N1),PRECIS0,LINETHICK0;
双底背离:底背离 and MINDIFFF<DIFF,PRECIS0,LINETHICK0;
VERTLINE(底背离 ,1 ),colorblue;
VERTLINE(双底背离 ,1 ),colorred;
drawbmp(ref(macd,1)<0 and macd>0,diff,'STSbuy1.bmp'),align1,valign0;
drawbmp(ref(macd,1)>0 and macd<0,diff,'STSsell1.bmp'),align1,valign1;