MACD在零轴下面三次金叉后,指标步步抬高,股价慢慢下跌形成与指标背离。
选股不含未来函数。
为了方便看盘 主图画线用未来函数画在三个股价低点。幅图画线在MACD的DIF三个低点。更加方便你在大级别背离后看看近期股价和指标是不是又背离了呢?
主图
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
T:=BARSLAST(CROSS(DIF,DEA) AND DIF
T1:=SUMBARS(T=0,2);
T2:=SUMBARS(T=0,3);
M:=BARSLAST(CROSS(0,MACD));
M1:=SUMBARS(M=0,2);
M2:=SUMBARS(M=0,3);
D1:=REF(DIF,BARSLAST(DIF=LLV(DIF,M+1)));
D2:=REF(D1,T1-1);
D3:=REF(D2,T1-1);
LT:=BARSLAST(L=LLV(L,M+1));
L1:=REF(L,LT);
L2:=REF(L1,T1-1);
L3:=REF(L2,T1-1);
XG:=T=0 AND L1 L2 AND L2 L3 AND D1 D2 AND D2
DRAWICON(XG,L*0.98,1);
VAR1:=BACKSET(XG,T2+REF(LT,T2-1));
VAR2:=BACKSET(XG,T1+REF(LT,T1-1));
VAR3:=BACKSET(XG,T+REF(LT,T)+1);
DRAWLINE(CROSS(VAR1=1,0.5),L,CROSS(VAR2=1,0.5) AND VAR1=1,L,0),COLORYELLOW,LINETHICK2;
DRAWLINE(CROSS(VAR2=1,0.5) AND VAR1=1,L,VAR1=1 AND VAR2=1 AND CROSS(VAR3=1,0.5),L,0),COLORMAGENTA,LINETHICK2;
幅图
DIF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIF,9);
MACD:(DIF-DEA)*2,COLORSTICK;
T:=BARSLAST(CROSS(DIF,DEA) AND DIF
T1:=SUMBARS(T=0,2);
T2:=SUMBARS(T=0,3);
M:=BARSLAST(CROSS(0,MACD));
M1:=SUMBARS(M=0,2);
M2:=SUMBARS(M=0,3);
D1:=REF(DIF,BARSLAST(DIF=LLV(DIF,M+1)));
D2:=REF(D1,T1-1);
D3:=REF(D2,T1-1);
LT:=BARSLAST(L=LLV(L,M+1));
MT:=BARSLAST(DIF=LLV(DIF,M+1));
L1:=REF(L,LT);
L2:=REF(L1,T1-1);
L3:=REF(L2,T1-1);
XG:=T=0 AND L1 L2 AND L2 L3 AND D1 D2 AND D2
VAR1:=BACKSET(XG,T2+REF(MT,T2-1));
VAR2:=BACKSET(XG,T1+REF(MT,T1-1));
VAR3:=BACKSET(XG,T+REF(MT,T)+1);
DRAWLINE(CROSS(VAR1=1,0.5),DIF,CROSS(VAR2=1,0.5) AND VAR1=1,DIF,0),COLORYELLOW,LINETHICK2;
DRAWLINE(CROSS(VAR2=1,0.5) AND VAR1=1,DIF,VAR1=1 AND VAR2=1 AND CROSS(VAR3=1,0.5),DIF,0),COLORMAGENTA,LINETHICK2;
DRAWICON(XG,DIF,25);
选股
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
T:=BARSLAST(CROSS(DIF,DEA) AND DIF
T1:=SUMBARS(T=0,2);
T2:=SUMBARS(T=0,3);
M:=BARSLAST(CROSS(0,MACD));
M1:=SUMBARS(M=0,2);
M2:=SUMBARS(M=0,3);
D1:=REF(DIF,BARSLAST(DIF=LLV(DIF,M+1)));
D2:=REF(D1,T1-1);
D3:=REF(D2,T1-1);
LT:=BARSLAST(L=LLV(L,M+1));
L1:=REF(L,LT);
L2:=REF(L1,T1-1);
L3:=REF(L2,T1-1);
XG:T=0 AND L1 L2 AND L2 L3 AND D1 D2 AND D2