老狼的四合一顶底背离公式源码及使用说明,(MACD,RSI,KDJ,DMI)(源码)
{四合一背离}
{研判原则:
这是MACD,RSI,KDJ,DMI指标组合的顶底背离指标,
0线上不同颜色柱是顶背离,也就是相对顶部,
0线下不同颜色的柱是底背离,也就是相对底部.
该指标的主要特点是:
运用MACD这个指标的同时可看到其它几个指标的顶底预测点位,
为你介入卖出股票提供全方位的参考.}
{大智慧}【已经修改了大智慧可以用】
DIFF :=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA :=EMA(DIFF,9);
MACD :=(DIFF-DEA)*2;
TR := SUM(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),14);
HD := HIGH-REF(HIGH,1);
LD := REF(LOW,1)-LOW;
PDM:= SUM(IF(HD>0 AND HD>LD,HD,0),14);
MDM:= SUM(IF(LD>0 AND LD>HD,LD,0),14);
PDI:= PDM*100/TR;
MDI:= MDM*100/TR;
A1:=BARSLAST(ref(cross("macd.diff"(12,26,9),"macd.dea"(12,26,9)),1));
B1:=ref(c,A1+1)>c and ref("macd.diff"(12,26,9),A1+1)<"macd.diff"(12,26,9) and cross("macd.diff"(12,26,9),"macd.dea"(12,26,9));
A2:=BARSLAST(ref(cross("kdj.k"(9,3,3),"kdj.d"(9,3,3)),1));
B2:=ref(c,A2+1)>c and ref("kdj.k"(9,3,3),A2+1)<"kdj.k"(9,3,3) and cross("kdj.k"(9,3,3),"kdj.d"(9,3,3));
A3:=BARSLAST(ref(cross("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24)),1));
B3:=ref(c,A3+1)>c and ref("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) and cross("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));
C1:=BARSLAST(ref(cross("macd.dea"(12,26,9),"macd.diff"(12,26,9)),1));
D1:=ref(c,C1+1)<c and ref("macd.diff"(12,26,9),C1+1)>"macd.diff"(12,26,9) and cross("macd.dea"(12,26,9),"macd.diff"(12,26,9));
C2:=BARSLAST(ref(cross("kdj.d"(9,3,3),"kdj.k"(9,3,3)),1));
D2:=ref(c,C2+1)<c and ref("kdj.k"(9,3,3),C2+1)>"kdj.k"(9,3,3) and cross("kdj.d"(9,3,3),"kdj.k"(9,3,3));
C3:=BARSLAST(ref(cross("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24)),1));
D3:=ref(c,C3+1)<c and ref("RSI.RSI1"(6,12,24),C3+1)>"RSI.RSI1"(6,12,24) and cross("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24));
C4:=BARSLAST(ref(cross(mdi,pdi),1));
D4:=ref(c,C+1)<c and ref(mdi,C4+1)>mdi and cross(mdi,pdi);
A4:=BARSLAST(ref(cross(PDI,MDI),1));
B4:=ref(c,A4+1)>c and ref(pdi,A4+1)<pdi and cross(pdi,mdi);
DMI底背:IF(B4>0,-0.1,0),COLOR0099FF,POINTDOT;
MACD底背:if(B1>0,-0.1,0),colorred,pointdot;
KDJ底背:if(B2>0,-0.1,0),colorff00ff,pointdot;
RSI底背:if(B3>0,-0.1,0),coloryellow,pointdot;
DMI顶背:IF(D4>0,0.1,0),COLORBLUE,POINTDOT;
MACD顶背:if(D1>0,0.1,0),color00ff00,pointdot;
KDJ顶背:if(D2>0,0.1,0),colorffcc66,pointdot;
RSI顶背:if(D3>0,0.1,0),colorwhite,pointdot;
STICKLINE(B1>0,-0.1,0,6,0),colorred;
STICKLINE(B2>0,-0.1,0,6,0),colorff00ff;
STICKLINE(B3>0,-0.1,0,6,0),coloryellow;
STICKLINE(d1>0,0.1,0,6,0),color00ff00;
STICKLINE(d2>0,0.1,0,6,0),colorffcc66;
STICKLINE(d3>0,0.1,0,6,0),colorwhite;
STICKLINE(B4>0,-0.1,0,6,0),color0099ff;
STICKLINE(D4>0,0.1,0,6,0),colorblue;
{通达信}
{分析家公式网 http://www.fxjgsw.com 整理}
{N1=12;N2=26;N3=9;N4=14;N5=24}
DIFF :=EMA(CLOSE,N1) - EMA(CLOSE,N2);
DEA :=EMA(DIFF,N3);
TR := SUM(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),N4);
HD := HIGH-REF(HIGH,1);
LD := REF(LOW,1)-LOW;
PDM:= SUM(IF(HD>0 AND HD>LD,HD,0),N4);
MDM:= SUM(IF(LD>0 AND LD>HD,LD,0),N4);
PDI:= PDM*100/TR;
MDI:= MDM*100/TR;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
A2:=BARSLAST(REF(CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3)),1));
B2:=REF(C,A2+1)>C AND REF("KDJ.K"(9,3,3),A2+1)<"KDJ.K"(9,3,3) AND CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3));
A3:=BARSLAST(REF(CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24)),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) AND CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
C2:=BARSLAST(REF(CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3)),1));
D2:=REF(C,C2+1)<C AND REF("KDJ.K"(9,3,3),C2+1)>"KDJ.K"(9,3,3) AND CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3));
C3:=BARSLAST(REF(CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24)),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(6,12,24),C3+1)>"RSI.RSI1"(6,12,24) AND CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24));
C4:=BARSLAST(REF(CROSS(MDI,PDI),1));
D4:=REF(C,C+1)<C AND REF(MDI,C4+1)>MDI AND CROSS(MDI,PDI);
A4:=BARSLAST(REF(CROSS(PDI,MDI),1));
B4:=REF(C,A4+1)>C AND REF(PDI,A4+1)<PDI AND CROSS(PDI,MDI);
DMI底背:IF(B4>0,-0.1,0),COLOR0099FF,POINTDOT;
MACD底背:IF(B1>0,-0.1,0),COLORRED,POINTDOT;
KDJ底背:IF(B2>0,-0.1,0),COLORFF00FF,POINTDOT;
RSI底背:IF(B3>0,-0.1,0),COLORYELLOW,POINTDOT;
DMI顶背:IF(D4>0,0.1,0),COLORBLUE,POINTDOT;
MACD顶背:IF(D1>0,0.1,0),COLOR00FF00,POINTDOT;
KDJ顶背:IF(D2>0,0.1,0),COLORFFCC66,POINTDOT;
RSI顶背:IF(D3>0,0.1,0),COLORWHITE,POINTDOT;
STICKLINE(B1>0,-0.1,0,3,0),COLORRED;
STICKLINE(B2>0,-0.1,0,3,0),COLORFF00FF;
STICKLINE(B3>0,-0.1,0,3,0),COLORYELLOW;
STICKLINE(D1>0,0.1,0,3,0),COLOR00FF00;
STICKLINE(D2>0,0.1,0,3,0),COLORFFCC66;
STICKLINE(D3>0,0.1,0,3,0),COLORWHITE;
STICKLINE(B4>0,-0.1,0,3,0),COLOR0099FF;
STICKLINE(D4>0,0.1,0,3,0),COLORBLUE;
|