通达信神马MACD指标公式
2021/6/3 19:22:31
MACD1:=12;
MACD2:=26;
MACD3:=9;
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIFF,9);
MACD:2*(DIFF-DEA),COLORSTICK;
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
一金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=1,21)=1;
STICKLINE(一金叉,0,0.1,3,0),COLOR0000FF;
DRAWTEXT(一金叉,-0.095,'一金叉红色'),COLOR0000FF;
二金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
STICKLINE(二金叉,0,0.10,3,0),COLORLIRED;
DRAWTEXT(二金叉,0.23,'二次金叉淡红色'),COLORLIRED;
三金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=3,28)=1;
STICKLINE(三金叉,0,0.1,3,0),COLORLIMAGENTA;
DRAWTEXT(三金叉,0.28,'三次金叉洋红色'),COLORLIMAGENTA;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=(REF(L,A1+1)>L OR REF(C,A1+1)>C) AND (L,DIFF)>REF((L,DIFF),A1+1) AND CROSS(DIFF,DEA);
STICKLINE(底背离,0,-0.1,5,0),COLORYELLOW;
DRAWTEXT(底背离,DEA,'底背离')COLORYELLOW;
DRAWLINE(A1=0,DEA,底背离,DEA,0),COLOR0000FF,LINETHICK3;
A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=(REF(C,A2+1)<C OR REF(H,A2+1)<H) AND REF((H,DIFF),A2+1)>(H,DIFF) AND CROSS(DEA,DIFF);
DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORGREEN,LINETHICK3;
STICKLINE(顶背离,0,0.1,6,0),COLORCYAN;
DRAWTEXT(顶背离,DEA,'顶背离')COLORCYAN;
IF(DIFF>DEA,DIFF,DRAWNULL),LINETHICK2;
IF(DEA>REF(DEA,1) AND DIFF>DEA,DEA,DRAWNULL),COLORYELLOW,LINETHICK2;
DIF:EMA(CLOSE,MACD1)-EMA(CLOSE,MACD2);
DRAWICON(CROSS(DIF,DEA),DIF,1);
DRAWICON(CROSS(DEA,DIF),DEA,2);
投股 票网 www.tou18 .cn
[源码翻译]通达信软件动态翻译的结果
MACD1赋值:12
MACD2赋值:26
MACD3赋值:9
输出DIFF:收盘价的12日指数移动平均-收盘价的26日指数移动平均
输出DEA:DIFF的9日指数移动平均
输出平滑异同平均:2*(DIFF-DEA),COLORSTICK
JCCOUNT赋值:统计上次DEA>=0距今天数日中满足DIFF上穿DEA的天数
一金叉赋值:DIFF上穿DEA AND DEA<0 AND 统计21日中满足JCCOUNT=1的天数=1
当满足条件一金叉时,在0和0.1位置之间画柱状线,宽度为3,0不为0则画空心柱.,COLOR0000FF
当满足条件一金叉时,在-0.095位置书写文字,COLOR0000FF
二金叉赋值:DIFF上穿DEA AND DEA<0 AND 统计21日中满足JCCOUNT=2的天数=1
当满足条件二金叉时,在0和0.10位置之间画柱状线,宽度为3,0不为0则画空心柱.,画淡红色
当满足条件二金叉时,在0.23位置书写文字,画淡红色
三金叉赋值:DIFF上穿DEA AND DEA<0 AND 统计28日中满足JCCOUNT=3的天数=1
当满足条件三金叉时,在0和0.1位置之间画柱状线,宽度为3,0不为0则画空心柱.,画淡洋红色
当满足条件三金叉时,在0.28位置书写文字,画淡洋红色
A1赋值:上次1日前的DIFF上穿DEA距今天数
底背离赋值:(A1+1日前的最低价>最低价 OR A1+1日前的收盘价>收盘价) AND (最低价,DIFF)>A1+1日前的(最低价,DIFF) AND DIFF上穿DEA
当满足条件底背离时,在0和-0.1位置之间画柱状线,宽度为5,0不为0则画空心柱.,画黄色
当满足条件底背离时,在DEA位置书写文字画黄色
当满足条件A1=0时,在DEA位置画直线起点,当满足条件底背离时,在DEA位置画直线终点,0表示是否延长.,COLOR0000FF,线宽为3
A2赋值:上次1日前的DEA上穿DIFF距今天数
顶背离赋值:(A2+1日前的收盘价<收盘价 OR A2+1日前的最高价<最高价) AND A2+1日前的(最高价,DIFF)>(最高价,DIFF) AND DEA上穿DIFF
当满足条件A2=0时,在DEA位置画直线起点,当满足条件顶背离时,在DEA位置画直线终点,0表示是否延长.,画绿色,线宽为3
当满足条件顶背离时,在0和0.1位置之间画柱状线,宽度为6,0不为0则画空心柱.,画青色
当满足条件顶背离时,在DEA位置书写文字画青色
如果DIFF>DEA,返回DIFF,否则返回无效数,线宽为2
如果DEA>1日前的DEAANDDIFF>DEA,返回DEA,否则返回无效数,画黄色,线宽为2
输出DIF:收盘价的MACD1日指数移动平均-收盘价的MACD2日指数移动平均
当满足条件DIF上穿DEA时,在DIF位置画1号图标
当满足条件DEA上穿DIF时,在DEA位置画2号图标
股市公式下载推荐