MACD周线三次金叉的公式,要求每一次金叉时,DEA要大于等于前一次DEA,同时第三次金叉在0轴附近。
公式模块
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
N:=6;{N天前MACD金叉}
M:=5;{金叉后MACD连续红柱天数(DIF>DEA)}
TJ:=BARSLAST(REF(EXIST(CROSS(DIF,DEA),(N-M)),M));
TS:=BARSLAST(REF(EXIST(CROSS(DEA,DIF),(N-M)),M));
JCCOUNT:=COUNT(NDAY(DIF,DEA,M),TJ);
SCCOUNT:=COUNT(NDAY(DEA,DIF,M),TS) AND TJ>TS;
金叉:=CROSS(DIF,DEA) ANDCOUNT(JCCOUNT=1,21)=1;
T1:=BARSLAST(金叉);
二金叉:=CROSS(DIF,DEA) ANDDEA>REF(DEA,T1) AND COUNT(JCCOUNT=2,21)=1;
T2:=BARSLAST(二金叉);
三金叉:CROSS(DIF,DEA) ANDDEA>REF(DEA,T2) AND COUNT(JCCOUNT=3,28)=1 AND COUNT(SCCOUNT>0,T2);