通达信MACD背离副图指标公式源码

通达信MACD背离副图指标公式源码注释:

输出DIFF:(收盘价的12日指数移动平均-收盘价的26日指数移动平均)*20,画白色,线宽为1
输出DEA:DIFF的9日指数移动平均,画黄色,线宽为1
输出MACD1:2*(DIFF-DEA),NODRAW
MACD2赋值:(3*MACD1+2*1日前的MACD1+2日前的MACD1)/6的1日指数移动平均
当满足条件MACD1>MACD2ANDMACD1>0时,在0和MACD1位置之间画柱状线,宽度为0,0不为0则画空心柱.,画红色
当满足条件MACD1>MACD2ANDMACD1<0时,在0和MACD1位置之间画柱状线,宽度为2,0不为0则画空心柱.,画洋红色
当满足条件MACD1<MACD2时,在0和MACD1位置之间画柱状线,宽度为0,0不为0则画空心柱.,画青色
当满足条件MACD1>0ANDMACD1<=1日前的MACD1时,在0和MACD1位置之间画柱状线,宽度为0,1不为0则画空心柱.,画红色
金叉赋值:DIFF上穿DEA AND DIFF<0
当满足条件金叉时,在0位置书写文字,画白色
金叉1赋值:DIFF上穿DEA AND DIFF>=0
当满足条件金叉1时,在0位置书写文字,画黄色
输出红柱面积:平滑异同平均线的上次平滑异同平均线<0距今天数日累和*(平滑异同平均线>0),画红色,NODRAW
输出绿柱面积:平滑异同平均线的上次平滑异同平均线>0距今天数日累和*(平滑异同平均线<0),画绿色,NODRAW
DIF1A赋值:收盘价的12日指数移动平均-收盘价的26日指数移动平均
DEA1A赋值:DIF1A的9日指数移动平均
MACDA赋值:(DIF1A-DEA1A)*2*60
低位金叉赋值:DIF1A上穿DEA1A AND DIF1A<-0.1
JCCOUNT赋值:统计上次DEA1A>=0距今天数日中满足DIF1A上穿DEA1A的天数
二次金叉赋值:DIF1A上穿DEA1A AND DEA1A<0 AND 统计21日中满足JCCOUNT=2的天数=1
A101赋值:上次1日前的DIF1A上穿DEA1A距今天数
底背离赋值:A101+1日前的收盘价>收盘价 AND DIF1A>A101+1日前的DIF1A AND DIF1A上穿DEA1A
当满足条件底背离时,在-3.5位置书写文字,画黄色

通达信MACD背离副图指标公式源码:

DIFF:(EMA(C,12)-EMA(C,26))*20,COLORWHITE,LINETHICK1;
DEA:EMA(DIFF,9),COLORYELLOW,LINETHICK1;
MACD1:2*(DIFF-DEA),NODRAW;
MACD2:=EMA((3*MACD1+2*REF(MACD1,1)+REF(MACD1,2))/6,1);
STICKLINE(MACD1>MACD2 AND MACD1>0,0,MACD1,0,0),COLORRED;
STICKLINE(MACD1>MACD2 AND MACD1<0,0,MACD1,2,0),COLORMAGENTA;
STICKLINE(MACD1<MACD2,0,MACD1,0,0),COLORCYAN;
STICKLINE(MACD1>0 AND MACD1<=REF(MACD1,1),0,MACD1,0,1),COLORRED;
金叉:=CROSS(DIFF,DEA) AND DIFF<0;
DRAWTEXT(金叉,0,' 金叉'),COLORWHITE;
金叉1:=CROSS(DIFF,DEA) AND DIFF>=0;
DRAWTEXT(金叉1,0,' 金叉'),COLORYELLOW;
红柱面积:SUM(MACD,BARSLAST(MACD<0))*(MACD>0),COLORRED,NODRAW;
绿柱面积:SUM(MACD,BARSLAST(MACD>0))*(MACD<0),COLORGREEN,NODRAW;
DIF1A:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA1A:=EMA(DIF1A,9);
MACDA:=(DIF1A-DEA1A)*2*60;
低位金叉:=CROSS(DIF1A,DEA1A) AND DIF1A<-0.1;
JCCOUNT:=COUNT(CROSS(DIF1A,DEA1A),BARSLAST(DEA1A>=0));
二次金叉:=CROSS(DIF1A,DEA1A) AND DEA1A<0 AND COUNT(JCCOUNT=2,21)=1;
A101:=BARSLAST(REF(CROSS(DIF1A,DEA1A),1));
底背离:=REF(CLOSE,A101+1)>CLOSE AND DIF1A>REF(DIF1A,A101+1) AND CROSS(DIF1A,DEA1A);
DRAWTEXT(底背离,-3.5,'背离'),COLORYELLOW;