您现在的位置:程序化交易>> 股票公式>> 大智慧>> 大智慧公式>>正文内容

老狼的四合一顶底背离公式公式、源码及使用说明,(MACD,RSI,KDJ,DMI)[大智慧公式]

相关标签:

 

老狼的四合一顶底背离公式源码及使用说明,(MACD,RSI,KDJ,DMI)(源码)

{四合一背离}

{研判原则:
这是MACD,RSI,KDJ,DMI指标组合的顶底背离指标,
0线上不同颜色柱是顶背离,也就是相对顶部,
0线下不同颜色的柱是底背离,也就是相对底部.
该指标的主要特点是:
运用MACD这个指标的同时可看到其它几个指标的顶底预测点位,
为你介入卖出股票提供全方位的参考.}

 

原理解析:

赋值:收盘价的12日指数移动平均 - 收盘价的26日指数移动平均
DEA赋值:DIFF的9日指数移动平均
赋值:(DIFF-DEA)*2
赋值: 最高价-最低价和最高价-1日前的收盘价的绝对值的较大值和最低价-1日前的收盘价的绝对值的较大值的14日累和
赋值: 最高价-1日前的最高价
赋值: 1日前的最低价-最低价
PDM赋值: 如果HD>0ANDHD>LD,返回HD,否则返回0的14日累和
MDM赋值: 如果LD>0ANDLD>HD,返回LD,否则返回0的14日累和
PDI赋值: PDM*100/真实波幅
MDI赋值: MDM*100/真实波幅
A1赋值:上次1日前的"平滑异同平均的DIFF"(12,26,9)上穿"平滑异同平均的DEA"(12,26,9)距今天数
B1赋值:A1+1日前的收盘价>收盘价 AND A1+1日前的"平滑异同平均的DIFF"(12,26,9)<"平滑异同平均的DIFF"(12,26,9) AND "平滑异同平均的DIFF"(12,26,9)上穿"平滑异同平均的DEA"(12,26,9)
A2赋值:上次1日前的"KDJ的K"(9,3,3)上穿"KDJ的D"(9,3,3)距今天数
B2赋值:A2+1日前的收盘价>收盘价 AND A2+1日前的"KDJ的K"(9,3,3)<"KDJ的K"(9,3,3) AND "KDJ的K"(9,3,3)上穿"KDJ的D"(9,3,3)
A3赋值:上次1日前的"RSI的RSI1"(6,12,24)上穿"RSI的RSI2"(6,12,24)距今天数
B3赋值:A3+1日前的收盘价>收盘价 AND A3+1日前的"RSI的RSI1"(6,12,24)<"RSI的RSI1"(6,12,24) AND "RSI的RSI1"(6,12,24)上穿"RSI的RSI2"(6,12,24)
C1赋值:上次1日前的"平滑异同平均的DEA"(12,26,9)上穿"平滑异同平均的DIFF"(12,26,9)距今天数
D1赋值:C1+1日前的收盘价<收盘价 AND C1+1日前的"平滑异同平均的DIFF"(12,26,9)>"平滑异同平均的DIFF"(12,26,9) AND "平滑异同平均的DEA"(12,26,9)上穿"平滑异同平均的DIFF"(12,26,9)
C2赋值:上次1日前的"KDJ的D"(9,3,3)上穿"KDJ的K"(9,3,3)距今天数
D2赋值:C2+1日前的收盘价<收盘价 AND C2+1日前的"KDJ的K"(9,3,3)>"KDJ的K"(9,3,3) AND "KDJ的D"(9,3,3)上穿"KDJ的K"(9,3,3)
C3赋值:上次1日前的"RSI的RSI2"(6,12,24)上穿"RSI的RSI1"(6,12,24)距今天数
D3赋值:C3+1日前的收盘价<收盘价 AND C3+1日前的"RSI的RSI1"(6,12,24)>"RSI的RSI1"(6,12,24) AND "RSI的RSI2"(6,12,24)上穿"RSI的RSI1"(6,12,24)
C4赋值:上次1日前的MDI上穿PDI距今天数
D4赋值:收盘价+1日前的收盘价<收盘价 AND C4+1日前的MDI>MDI AND MDI上穿PDI
A4赋值:上次1日前的PDI上穿MDI距今天数
B4赋值:A4+1日前的收盘价>收盘价 AND A4+1日前的PDI<PDI AND PDI上穿MDI
输出DMI底背:如果B4>0,返回-0.1,否则返回0,COLOR0099FF,POINTDOT
输出MACD底背:如果B1>0,返回-0.1,否则返回0,画红色,POINTDOT
输出KDJ底背:如果B2>0,返回-0.1,否则返回0,COLORFF00FF,POINTDOT
输出RSI底背:如果B3>0,返回-0.1,否则返回0,画黄色,POINTDOT
 

源码:

{大智慧}【已经修改了大智慧可以用】
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;{http://cxh99.com}
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..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;{http://cxh99.com}
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;

 

公式导入教程: 【通达信公式源码导入方法教程】 【同花顺公式源码导入方法教程】 【大智慧新一代公式源码导入方法教程

 

 

有思路,想编写各种指标公式,交易模型,选股公式,还原公式的朋友

可联系技术人员 QQ: 262069696  点击在线交流或微信:cxhjy888 进行 有偿收费 编写!(注:由于人数限制,QQ或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)

怎么收费,代编流程等详情请点击查阅!

(注:由于人数限制,QQ或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)

 


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容