彩色MACD通达信公式 副图 源码附图无未来函数
DIFIF1:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEAEA1:=EMA(DIFIF1,9);
MACD1:=2*(DIFIF1-DEAEA1),STICK;
MACD2:=EMA(MACD1,3);
STICKLINE(MACD1>MACD2 AND MACD1>0,0,MACD1,0.2,0),COLORRED;
STICKLINE(MACD1>MACD2 AND MACD1<0,0,MACD1,0.2,0),COLORGREEN;
STICKLINE(MACD1<MACD2,0,MACD1,0.2,0),COLORCBCBC0;
STICKLINE(MACD1>=0 OR MACD1<=0,0,0,20,1),COLORWHITE;
DIFIF1,COLOR33FF33,LINETHICK1;
DEAEA1,COLORYELLOW,LINETHICK1;
MACD:MACD1,NODRAW,COLORMAGENTA;
DRAWTEXT(CROSS(DIFIF1,DEAEA1) AND DIFIF1<1,DIFIF1,'↑买'),LINETHICK1, COLORYELLOW;
DRAWTEXT(CROSS(DEAEA1,DIFIF1)AND MACD<REF(MACD,1),DEAEA1,'↓卖'),LINETHICK1, COLORGREEN;
红面积:IF(DIFIF1>DEAEA1,SUM(MACD,BARSLAST(CROSS(DIFIF1,DEAEA1))),DRAWNULL),NODRAW,COLORLIRED;
绿面积:IF(DIFIF1<DEAEA1,SUM(MACD,BARSLAST(CROSS(DEAEA1,DIFIF1))),DRAWNULL),NODRAW,COLORGREEN;
DRAWNUMBER(CROSS(DIFIF1,DEAEA1),DEAEA1,REF(绿面积,1)),COLORGREEN;
DRAWNUMBER(CROSS(DEAEA1,DIFIF1),DEAEA1*1.1,REF(红面积,1)),COLORLIRED;
DRAWNUMBER(DIFIF1>DEAEA1,MACD,BARSLAST(CROSS(DIFIF1,DEAEA1))+1),COLORRED;
DRAWNUMBER(DIFIF1<DEAEA1,MACD,BARSLAST(CROSS(DEAEA1,DIFIF1))+1),COLORCYAN;
DIF:=EMA(C+SLOPE(C,12),12)-EMA(C+SLOPE(C,26),26),COLORWHITE;
DEA:=EMA(DIF+SLOPE(DIF,6),6),COLORGREEN;
SDEA:REF(HHV(DEA,BARSLAST(CROSS(DEA,DIF))+1),1),COLORMAGENTA;
BDEA:REF(LLV(DEA,BARSLAST(CROSS(DIF,DEA))+1),1),COLORAAAA00;
CD:MACD,COLORCYAN;
涨CD:IF(CD>REF(CD,1),CD,DRAWNULL),COLORRED,LINETHICK1;
涨DIFIF1:IF(DIFIF1>REF(DIFIF1,1),DIFIF1,DRAWNULL),COLORRED,LINETHICK1;
A1:=BARSLAST(REF(CROSS(DIFIF1,DEAEA1),1));
多空分界线:0,COLORGREEN;
来函数检测结果如下:
该公式没有未来函数
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
DIFIF1赋值:收盘价的12日指数移动平均 - 收盘价的26日指数移动平均
DEAEA1赋值:DIFIF1的9日指数移动平均
MACD1赋值:2*(DIFIF1-DEAEA1),STICK
MACD2赋值:MACD1的3日指数移动平均
当满足条件MACD1>MACD2 AND MACD1>0时,在0和MACD1之间画柱状线
当满足条件MACD1>MACD2 AND MACD1<0时,在0和MACD1之间画柱状线
当满足条件MACD1当满足条件MACD1>=0 OR MACD1<=0时,在0和0之间画柱状线
DIFIF1,COLOR33FF33,LINETHICK1
DEAEA1,画黄色,LINETHICK1
输出
MACD:MACD1,NODRAW,画洋红色
DRAWTEXT(DIFIF1上穿DEAEA1 AND DIFIF1<1,DIFIF1,'↑买'),LINETHICK1, 画黄色
DRAWTEXT(DEAEA1上穿DIFIF1AND MACD<1日前的MACD,DEAEA1,'↓卖'),LINETHICK1, 画绿色
输出
红面积:IF(DIFIF1>DEAEA1,SUM(MACD,上次DIFIF1上穿DEAEA1距今天数),DRAWNULL),NODRAW,COLORLIRED
输出
绿面积:IF(DIFIF1
DRAWNUMBER(DIFIF1上穿DEAEA1,DEAEA1,1日前的绿面积),画绿色
DRAWNUMBER(DEAEA1上穿DIFIF1,DEAEA1*1.1,1日前的红面积),COLORLIRED
DRAWNUMBER(DIFIF1>DEAEA1,MACD,上次DIFIF1上穿DEAEA1距今天数+1),画红色
DRAWNUMBER(DIFIF1
DIF赋值:EMA(C+SLOPE(C,12),12)-EMA(C+SLOPE(C,26),26),画白色
DEA赋值:EMA(DIF+SLOPE(DIF,6),6),画绿色
输出
SDEA:REF(HHV(DEA,上次DEA上穿DIF距今天数+1),1),画洋红色
输出
BDEA:REF(LLV(DEA,上次DIF上穿DEA距今天数+1),1),COLORAAAA00
输出
CD:MACD,画青色
输出
涨CD:IF(CD>1日前的CD,CD,DRAWNULL),画红色,LINETHICK1
涨输出DIFIF1:IF(DIFIF1>1日前的DIFIF1,DIFIF1,DRAWNULL),画红色,LINETHICK1
A1赋值:上次1日前的DIFIF1上穿DEAEA1距今天数
输出
多空分界线:0,画绿色