通达信MACD短期指标公式

 

SHORT:=12;
LONG:=26;
MID:=9;
DIFF :(EMA(C,SHORT) - EMA(C,LONG))*1000;
DEA :EMA(DIFF,MID);
macd :2*(DIFF-DEA),COLORSTICK;
A0:=BArslAST(REF(crOSS(DEA,0),1));
A1:=BARSLAST(CROSS(DEA,DIFF));
A2:=REF(BARSLAST(CROSS(DEA,DIFF)),A1+1);
A3:=REF(BARSLAST(CROSS(DEA,DIFF)),A2+A1+2);
A4:=REF(BARSLAST(CROSS(DEA,DIFF)),A3+A2+A1+3);
A5:=REF(BARSLAST(CROSS(DEA,DIFF)),A4+A3+A2+A1+4);
A11:=LLV(C,A1)<REF(LLV(C,A1+1),A1+1) AND LLV(DIFF,A1)>REF(LLV(DIFF,A1+1),A1+1);
A22:=LLV(C,A1)<REF(LLV(C,A1+A2+2),A1+A2+2) AND
LLV(DIFF,A1)>REF(LLV(DIFF,A1+A2+2),A1+A2+2);
A33:=LLV(C,A1)<REF(LLV(C,A1+A2+A3+3),A1+A2+A3+3) AND
LLV(DIFF,A1)>REF(LLV(DIFF,A1+A2+A3+3),A1+A2+A3+3);
A44:=LLV(C,A1)<REF(LLV(C,A1+A2+A3+A4+4),A1+A2+A3+A4+4) AND
LLV(DIFF,A1)>REF(LLV(DIFF,A1+A2+A3+A4+4),A1+A2+A3+A4+4) AND A11 AND A22 AND A33;
A55:=LLV(C,A1)<REF(LLV(C,A1+A2+A3+A4+A5+5),A1+A2+A3+A4+A5+5) AND
LLV(DIFF,A1)>REF(LLV(DIFF,A1+A2+A3+A4+A5+5),A1+A2+A3+A4+A5+5) AND A11 AND A22 AND A33
AND A44;
DIBL:=(A11 OR A22 OR A33 OR A44 OR A55) AND DIFF<0 AND REF(COUNT(MacD<0,2)=2,1) AND CROSS(DIFF,DEA);
DIBL1:=(A11 OR A22 OR A33 OR A44 OR A55) AND DIFF<0 AND DIFF<DEA AND DIFF>REF(DIFF,1)
AND DIFF>REF(DIFF,2);
底背离:IF(DIBL,0,DEA),COLORRED;
IF(DIFF<0 AND CROSS(DIFF,DEA) AND DIBL=0,0,DEA),COLORYELLOW;
B0:=BARSLAST(REF(CROSS(0,DEA),1));
B1:=BARSLAST(CROSS(DIFF,DEA));
B2:=REF(BARSLAST(CROSS(DIFF,DEA)),B1+1);
B3:=REF(BARSLAST(CROSS(DIFF,DEA)),B1+B2+2);
B4:=REF(BARSLAST(CROSS(DIFF,DEA)),B1+B2+B3+3);
B5:=REF(BARSLAST(CROSS(DIFF,DEA)),B1+B2+B3+B4+4);
B11:=HHV(C,B1)>REF(HHV(C,B1+1),B1+1) AND HHV(DIFF,B1)<REF(HHV(DIFF,B1+1),B1+1);
B22:=HHV(C,B1)>REF(HHV(C,B1+B2+2),B1+B2+2) AND
HHV(DIFF,B1)<REF(HHV(DIFF,B1+B2+2),B1+B2+2);
B33:=HHV(C,B1)>REF(HHV(C,B1+B2+B3+3),B1+B2+B3+3) AND
HHV(DIFF,B1)<REF(HHV(DIFF,B1+B2+B3+3),B1+B2+B3+3);
B44:=HHV(C,B1)>REF(HHV(C,B1+B2+B3+B4+4),B1+B2+B3+B4+4) AND
HHV(DIFF,B1)<REF(HHV(DIFF,B1+B2+B3+B4+4),B1+B2+B3+B4+4) AND B11 AND B22 AND B33;
B55:=HHV(C,B1)>REF(HHV(C,B1+B2+B3+B4+B5+5),B1+B2+B3+B4+B5+5) AND
HHV(DIFF,B1)<REF(HHV(DIFF,B1+B2+B3+B4+B5+5),B1+B2+B3+B4+B5+5) AND B11 AND B22 AND B33
AND B44;
DINGBL:=(B11 OR B22 OR B33 OR B44 OR B55) AND DIFF>0 AND REF(COUNT(MACD>0,2)=2,1) AND CROSS(DEA,DIFF);
DINGBL1:=(B11 OR B22 OR B33 OR B44 OR B55) AND DIFF>0 AND DEA<DIFF AND DIFF<REF(DIFF,1)
AND DIFF<REF(DIFF,2);
顶背离:IF(DINGBL,0,DEA),COLORGREEN;
IF(DIFF>0 AND CROSS(DEA,DIFF) AND DINGBL=0,0,DEA),COLORBLUE;
STICKLINE(DIBL1,DIFF,DEA,2,0),COLORRED;
STICKLINE(DINGBL1,DIFF,DEA,2,0),COLORGREEN;
MB:=EMA(DIFF,20);
UB:=MB+1.9104*STD(DIFF,20),COLORYELLOW,POINTDOT;
LB:=MB-1.9104*STD(DIFF,20),COLORLIBLUE,POINTDOT;
ZJS:=HHV(DEA,B0)/2;
ZJX:=LLV(DEA,A0)/2;
IF(DEA>DIFF AND DIFF>0 ,ZJS,DRAWNULL),COLORRED;
IF(DEA<DIFF AND DIFF<0 ,ZJX,DRAWNULL),COLORGREEN;




来函数检测结果如下
该公式没有未来函数


解密、定制、编写公式指标请联系QQ或微信同号:88652583
置顶指标

相关指标公式

SHORT赋值:12
LONG赋值:26
MID赋值:9
输出DIFF :(收盘价的SHORT日指数移动平均 - 收盘价的LONG日指数移动平均)*1000
输出DEA :DIFF的MID日指数移动平均
输出平滑异同平均线 :2*(DIFF-DEA),COLORSTICK
A0赋值:上次1日前的DEA上穿0距今天数
A1赋值:上次DEA上穿DIFF距今天数
A2赋值:A1+1日前的上次DEA上穿DIFF距今天数
A3赋值:A2+A1+2日前的上次DEA上穿DIFF距今天数
A4赋值:A3+A2+A1+3日前的上次DEA上穿DIFF距今天数
A5赋值:A4+A3+A2+A1+4日前的上次DEA上穿DIFF距今天数
A11赋值:A1日内收盘价的最低值A1+1日前的A1+1日内DIFF的最低值
A22赋值:A1日内收盘价的最低值A1+A2+2日前的A1+A2+2日内DIFF的最低值
A33赋值:A1日内收盘价的最低值A1+A2+A3+3日前的A1+A2+A3+3日内DIFF的最低值
A44赋值:A1日内收盘价的最低值A1+A2+A3+A4+4日前的A1+A2+A3+A4+4日内DIFF的最低值 AND A11 AND A22 AND A33
A55赋值:A1日内收盘价的最低值A1+A2+A3+A4+A5+5日前的A1+A2+A3+A4+A5+5日内DIFF的最低值 AND A11 AND A22 AND A33AND A44
DIBL赋值:(A11 OR A22 OR A33 OR A44 OR A55) AND DIFF<0 AND 1日前的统计2日中满足平滑异同平均线<0的天数=2 AND DIFF上穿DEA
DIBL1赋值:(A11 OR A22 OR A33 OR A44 OR A55) AND DIFF<0 AND DIFF1日前的DIFFAND DIFF>2日前的DIFF
输出底背离:如果DIBL,返回0,否则返回DEA,画红色
如果DIFF<0ANDCROSS(DIFF,DEA)ANDDIBL=0,返回0,否则返回DEA,画黄色
B0赋值:上次1日前的0上穿DEA距今天数
B1赋值:上次DIFF上穿DEA距今天数
B2赋值:B1+1日前的上次DIFF上穿DEA距今天数
B3赋值:B1+B2+2日前的上次DIFF上穿DEA距今天数
B4赋值:B1+B2+B3+3日前的上次DIFF上穿DEA距今天数
B5赋值:B1+B2+B3+B4+4日前的上次DIFF上穿DEA距今天数
B11赋值:B1日内收盘价的最高值>B1+1日前的B1+1日内收盘价的最高值 AND B1日内DIFF的最高值B22赋值:B1日内收盘价的最高值>B1+B2+2日前的B1+B2+2日内收盘价的最高值 ANDHHV(DIFF,B1)B33赋值:B1日内收盘价的最高值>B1+B2+B3+3日前的B1+B2+B3+3日内收盘价的最高值 ANDHHV(DIFF,B1)B44赋值:B1日内收盘价的最高值>B1+B2+B3+B4+4日前的B1+B2+B3+B4+4日内收盘价的最高值 ANDHHV(DIFF,B1)B55赋值:B1日内收盘价的最高值>B1+B2+B3+B4+B5+5日前的B1+B2+B3+B4+B5+5日内收盘价的最高值 ANDHHV(DIFF,B1)DINGBL赋值:(B11 OR B22 OR B33 OR B44 OR B55) AND DIFF>0 AND 1日前的统计2日中满足平滑异同平均线>0的天数=2 AND DEA上穿DIFF
DINGBL1赋值:(B11 OR B22 OR B33 OR B44 OR B55) AND DIFF>0 AND DEA输出顶背离:如果DINGBL,返回0,否则返回DEA,画绿色
如果DIFF>0ANDCROSS(DEA,DIFF)ANDDINGBL=0,返回0,否则返回DEA,画蓝色
当满足条件DIBL1时,在DIFF和DEA位置之间画柱状线,宽度为2,0不为0则画空心柱.,画红色
当满足条件DINGBL1时,在DIFF和DEA位置之间画柱状线,宽度为2,0不为0则画空心柱.,画绿色
MB赋值:DIFF的20日指数移动平均
UB赋值:MB+1.9104*DIFF的20日估算标准差,画黄色,POINTDOT
LB赋值:MB-1.9104*DIFF的20日估算标准差,画淡蓝色,POINTDOT
ZJS赋值:B0日内DEA的最高值/2
ZJX赋值:A0日内DEA的最低值/2
如果DEA>DIFFANDDIFF>0,返回ZJS,否则返回无效数,画红色
如果DEA

指标安装下载帮助  |   联系我们  |  乐淘公式网  |  公式网   |  指标公式  |   加入收藏   |  设为主页

@2005-2025 浙ICP备2024071487号-1 乐淘公式网公式网均来源互联网收集整理,如不慎侵犯了你的权益,请联系我们告知,我们将做删除处理
免责声明:乐淘公式网所有指标公式及文章由网络收集,不保障实时性和真实性, 仅供学习研究并不构成投资建议,请勿以此为依据进行股票交易,由此引起的投资亏损与本站无关。
QQ:88652583 微信 88652583
sitemap站点地图