通达信背离源码指标

[复制链接]
查看181 | 回复0 | 2021-8-21 04:28:12 | 显示全部楼层 |阅读模式

以下是通达信背离源码指标(无源码的请下载附件导入)

编写要求:

 

公式指标网解答:

 网友求助:

MACD、RSI、KDJ…背离指标公式:


ma1:MA(C,5);
ma2:MA(C,10);
ma3:MA(C,30);
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));
底背离MACD:DRAWTEXT(FILTER(B1>0,5),LOW,'1'),coloryellow;
DRAWTEXT(FILTER(B1>0,5),LOW*0.98,'MACD底背离'),COLOR00ff00;
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));
底背离KDJ:DRAWTEXT(FILTER(B2>0,5),LOW,'▲'),coloryellow;
DRAWTEXT(FILTER(B2>0,5),LOW*0.98,'KDJ底背离'),colorred;
A3:=BARSLAST(REF(CROSS("RSI.RSI1"(12,26,9),"RSI.RSI2"(12,26,9)),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(8,55,55),A3+1)<"RSI.RSI1"(8,55,55) AND CROSS("RSI.RSI1"(8,55,55),"RSI.RSI2"(8,55,55));
底背离RSI:DRAWTEXT(FILTER(B3>0,5),LOW,'▲'),coloryellow;
DRAWTEXT(FILTER(B3>0,5),LOW*0.98,'RSI底背离'),colorf0f000;
A4:=BARSLAST(REF(CROSS("dmi_ql.pdi"(14,6),"dmi_ql.mdi"(14,6)),1));
B4:=REF(C,A4+1)>C AND REF("dmi_ql.pdi"(14,6),A4+1)<"dmi_ql.pdi"(14,6) AND CROSS("dmi_ql.pdi"(14,6),"dmi_ql.mdi"(14,6));
底背离DMI:DRAWTEXT(FILTER(B4>0,5),LOW,'▲'),coloryellow;
DRAWTEXT(FILTER(B4>0,5),LOW*0.98,'DMI底背离'),colorF00FF0;
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));
顶背离MACD:DRAWTEXT(FILTER(D1>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D1>0,5),HIGH*1.04,'MACD顶背离'),colorred;
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));
顶背离KDJ:DRAWTEXT(FILTER(D2>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D2>0,5),HIGH*1.04,'KDJ顶背离'),COLORF00FF0;
C3:=BARSLAST(REF(CROSS("RSI.RSI2"(8,55,55),"RSI.RSI1"(8,55,55)),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(8,55,55),C3+1)>"RSI.RSI1"(8,55,55) AND CROSS("RSI.RSI2"(8,55,55),"RSI.RSI1"(8,55,55));
顶背离RSI:DRAWTEXT(FILTER(D3>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D3>0,5),HIGH*1.04,'RSI顶背离'),coloryellow;
C4:=BARSLAST(REF(CROSS("DMI_ql.MDI"(14,6),"DMI_ql.PDI"(14,6)),1));
D4:=REF(C,C4+1)<C AND REF("DMI_ql.PDI"(14,6),C4+1)>"DMI_ql.PDI"(14,6) AND CROSS("DMI_ql.MDI"(14,6),"DMI_ql.PDI"(14,6));
顶背离DMI:DRAWTEXT(FILTER(D4>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D4>0,5),HIGH*1.04,'DMI顶背离'),COLORF0F000;

 

646333847.png

646333847.png

解答如下:
MA1:MA(C,5);
MA2:MA(C,10);
MA3:MA(C,30);
A1:=BARSLAST(REF(CROSS("MACD.DIF"(12,26,9),"MACD.DEA"(12,26,9)),1));
B1:=REF(C,A1+1)>C AND REF("MACD.DIF"(12,26,9),A1+1)<"MACD.DIF"(12,26,9) AND CROSS("MACD.DIF"(12,26,9),"MACD.DEA"(12,26,9));
底背离MACD:DRAWTEXT(FILTER(B1>0,5),LOW,'1'),COLORYELLOW;
DRAWTEXT(FILTER(B1>0,5),LOW*0.98,'MACD底背离'),COLOR00FF00;
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));
底背离KDJ:DRAWTEXT(FILTER(B2>0,5),LOW,'▲'),COLORYELLOW;
DRAWTEXT(FILTER(B2>0,5),LOW*0.98,'KDJ底背离'),COLORRED;
A3:=BARSLAST(REF(CROSS("RSI.RSI1"(12,26,9),"RSI.RSI2"(12,26,9)),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(8,55,55),A3+1)<"RSI.RSI1"(8,55,55) AND CROSS("RSI.RSI1"(8,55,55),"RSI.RSI2"(8,55,55));
底背离RSI:DRAWTEXT(FILTER(B3>0,5),LOW,'▲'),COLORYELLOW;
DRAWTEXT(FILTER(B3>0,5),LOW*0.98,'RSI底背离'),COLORF0F000;
A4:=BARSLAST(REF(CROSS("DMI.PDI"(14,6),"DMI.MDI"(14,6)),1));
B4:=REF(C,A4+1)>C AND REF("DMI.PDI"(14,6),A4+1)<"DMI.PDI"(14,6) AND CROSS("DMI.PDI"(14,6),"DMI.MDI"(14,6));
底背离DMI:DRAWTEXT(FILTER(B4>0,5),LOW,'▲'),COLORYELLOW;
DRAWTEXT(FILTER(B4>0,5),LOW*0.98,'DMI底背离'),COLORF00FF0;
C1:=BARSLAST(REF(CROSS("MACD.DEA"(12,26,9),"MACD.DIF"(12,26,9)),1));
D1:=REF(C,C1+1)<C AND REF("MACD.DIF"(12,26,9),C1+1)>"MACD.DIF"(12,26,9) AND CROSS("MACD.DEA"(12,26,9),"MACD.DIF"(12,26,9));
顶背离MACD:DRAWTEXT(FILTER(D1>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D1>0,5),HIGH*1.04,'MACD顶背离'),COLORRED;
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));
顶背离KDJ:DRAWTEXT(FILTER(D2>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D2>0,5),HIGH*1.04,'KDJ顶背离'),COLORF00FF0;
C3:=BARSLAST(REF(CROSS("RSI.RSI2"(8,55,55),"RSI.RSI1"(8,55,55)),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(8,55,55),C3+1)>"RSI.RSI1"(8,55,55) AND CROSS("RSI.RSI2"(8,55,55),"RSI.RSI1"(8,55,55));
顶背离RSI:DRAWTEXT(FILTER(D3>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D3>0,5),HIGH*1.04,'RSI顶背离'),COLORYELLOW;
C4:=BARSLAST(REF(CROSS("DMI.MDI"(14,6),"DMI.PDI"(14,6)),1));
D4:=REF(C,C4+1)<C AND REF("DMI.PDI"(14,6),C4+1)>"DMI.PDI"(14,6) AND CROSS("DMI.MDI"(14,6),"DMI.PDI"(14,6));
顶背离DMI:DRAWTEXT(FILTER(D4>0,5),HIGH*1.02,'▲'),COLOR00FF00;
DRAWTEXT(FILTER(D4>0,5),HIGH*1.04,'DMI顶背离'),COLORF0F000;
 
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则