MACD底背離的通達信選股公式
飛狐源碼(macd背離)
DIFF : EMA(CLOSE,S) - EMA(CLOSE,P),colorred;//(這句表達的是S天與P天股價指數(shù)平滑曲線的差值,用紅色表示)
DEA : EMA(DIFF,M),coloryellow;//(這句表達的是第一句M天的指數(shù)平滑曲線,用黃色表示)
MACD : 2*(DIFF-DEA), COLORSTICK;//(這句表達的第一句和第二句差值的柱狀線)
A4:=BARSLAST(ref(cross(diff,dea),1));
B1:=ref(h,A4+3)>ref(c,3) and ref(diff,A4+3)<ref(diff,3) and cross(diff,dea);
DRAWTEXT(FILTER(B1>0,5),diff,'←底背離'),COLORyellow;
A5:=BARSLAST(ref(cross(dea,diff),1));
B2:=ref(h,A5+3)<ref(h,3) and ref(diff,A5+3)>ref(diff,3) and cross(dea,diff);
DRAWTEXT(FILTER(B2>0,5),diff,'←頂背離'),COLORgreen;
partline(diff<ref(diff,1),diff),colorgreen;//(這句是我自己加的,DIFF上升紅色,下降綠色,方便看盤而已,飛狐可用)。
----------------------------
大智慧(macd背離)
[MACD頂?shù)妆畴x] 參數(shù) short=12 long=26 m=9 n=55
DIFF:EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA:EMA(DIFF,M);
MACD:2*(DIFF-DEA), COLORSTICK;
底背離:LLV(L,N)=L AND NOT(LLV(MACD,N)=MACD),COLORFF00FF;
頂背離:HHV(H,N)=H AND NOT(HHV(MACD,N)=MACD),COLORFFFFFF;
-----------------------
MACD 底背離選股 原碼
DIFF := EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA := EMA(DIFF,M);
MACD := 2*(DIFF-DEA);
JC:=CROSS(DIFF,DEA);
T:=BARSLAST( DEA>0);
T1:=LLVBARS(DIFF,T);
REF(CLOSE,T1)>CLOSE AND REF(DIFF,T1)<DIFF AND
REF(MACD,1)<MACD AND ALL(DIFF<0,T) AND T1>15 AND
COUNT(JC,T)>=1;
以上參數(shù)LONG,SHORT, M需設(shè)置,缺省分別為26,12,9。
說明
1)T:=BARSLAST( DEA>0);語句取得dea跌入0線的周期;
2)T1:=LLVBARS(DIFF,T);語句取得dea跌入0線后的diff最低值周期;
3)ALL(DIFF<0,T)語句保證選出的股票在T周期內(nèi)diff沒有大于0。
4)T1>15 保證第一次金叉的時間距今天大于15日,是否合理?
---------------------
-------------------
條件選股公式:
macd背離的公式選股器
DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
FILTER(B1>0,5)
條件選股公式:
macd,RSi,kdj底背離
KDJ_K:="KDJ.K"(9,3,3);KDJ_D:="KDJ.D"(9,3,3);KDJ_J:="KDJ.J"(9,3,3);
買1:=CROSS(KDJ_J,0) OR (CROSS(KDJ_J,KDJ_K) AND KDJ_D<26);
買2:=CROSS("RSI.RSI1"(6,2,2),20) OR CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));
買3:=CROSS("MACD.DIF","MACD.DEA") OR CROSS("MACD.MACD",0);
買0:=買1+買2+買3;
買:IF(買0>1,買0,0);
通達信百發(fā)百中
{百發(fā)百中 K:100,120,105}
VARA:=CLOSE/MA(CLOSE,48)*100<71*K/100;
VARB:=CLOSE/MA(CLOSE,50)*100<70*K/100;
VARC:=HIGH/LOW>1.078/K*100;
VARD:=VARC AND COUNT(VARC,4)>2;
VAR1:=CLOSE;
VAR2:=MA(VAR1,6);
VAR3:=MA(VAR1,24);
VAR4:=MA(VAR1,32);
VAR5:=MA(VAR1,62);
VAR6:=MA(VAR1,105);
百:=VAR5/VAR6*100;發(fā):=VAR4/VAR2*100;中:=VAR3/VAR2*100;
財:=VAR2/VAR1*100;入:=CLOSE/COST(8)*100;
((發(fā)>110/K*100 AND 入<80*K/100) OR (VARD AND (VARA OR VARB)))
AND (HIGH>LOW) AND (REF(HIGH,1)>REF(LOW,1)) AND
(REF(HIGH,2)>REF(LOW,2)) AND (REF(HIGH,3)>REF(LOW,3)) AND
(REF(HIGH,4)>REF(LOW,4)) AND (REF(HIGH,5)>REF(LOW,5));
1)KDJ和RSI在20以下鈍化一段時間;2)MACD綠線逐漸縮短,且DIF上穿DAE而DEA也向上運行;3)日線向SAR靠攏并交叉;4)ROC在超賣區(qū)上穿MROC并且MROC上行;5)BOLL開口放大;6)5日線走平并上穿10日線且10日線走平并向上。
試著將上述條件編成一公式,經(jīng)測試,結(jié)果為零。于是,刪除并放寬一些條件,有如下公式:
DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
AA1:=DIFF<0 AND DIFF>=DEA AND DEA>REF(DEA,1)AND MACD>REF(MACD,1);
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
AA2:=3*K-2*D<25;
LC:= REF(CLOSE,1);
AA3:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100<30;
ROC:=(CLOSE-REF(CLOSE,12))/REF(CLOSE,12)*100;
ROCMA:=MA(ROC,6);
AA4:=ROCMA<0 AND ROC>=ROCMA AND ROCMA>REF(ROCMA,1);
AA5:=C<SAR(10,2,20)OR CROSS(C,SAR(10,2,20));
MID:=MA(CLOSE,26);
UPPER:=MID+2*STD(CLOSE,26);
AA1 AND AA2 AND AA3 AND AA4 AND AA5;
大家可再減少一些條件試試,信號會逐步增多。比如去掉最后兩個后,成功率仍是百分之百,而信號由6個增加到10個。