通达信MACD背离指标 源码
DIFF9:=(EMA(CLOSE,12)-EMA(CLOSE,26))*100/EMA(CLOSE,26),COLORRED;
DEA9:=EMA(DIFF9,9),COLORRED,LINETHICK2;
MACD:2*(DIFF9-DEA9), COLORSTICK,LINETHICK2;
A1:=BARSLAST(REF(CROSS(DIFF9,DEA9),1));
背离:=REF(CLOSE,A1+1)>CLOSE AND DIFF9>REF(DIFF9,A1+1) AND CROSS(DIFF9,DEA9);
STICKLINE(背离,0,DEA9,2,0),COLOR00FF00;
DRAWTEXT(背离,DEA9,' 背离');{股票指标网}
STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,0.5,0),COLORFF99AA;
STICKLINE(MACD<REF(MACD,1)AND MACD<0,0,MACD,0.5,0),COLORBLUE;
STICKLINE(MACD>REF(MACD,1)AND MACD,0,MACD,0.5,0),COLORGRAY;
STICKLINE(MACD>REF(MACD,1)AND MACD>0,0,MACD,0.5,0),COLORMAGENTA;
DIFF :(EMA(CLOSE,12)-EMA(CLOSE,26))*100/EMA(CLOSE,26),COLORRED;
DEA : EMA(DIFF9,9),COLORRED,LINETHICK2;
IF(DIFF9<REF(DIFF9,1),DIFF9,DRAWNULL),COLORGREEN;
IF(DEA9<REF(DEA9,1),DEA9,DRAWNULL),COLORGREEN,LINETHICK2;
来函数检测结果如下:
该公式没有未来函数
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
DIFF9赋值:(收盘价的12日指数移动平均-收盘价的26日指数移动平均)*100/收盘价的26日指数移动平均,画红色
DEA9赋值:DIFF9的9日指数移动平均,画红色, 线宽为2
输出
MACD:2*(DIFF9-DEA9), COLORSTICK, 线宽为2
A1赋值:上次1日前的DIFF9上穿DEA9距今天数
背离赋值:A1+1日前的收盘价>收盘价 AND DIFF9>A1+1日前的DIFF9 AND DIFF9上穿DEA9
当满足条件背离时,在0和DEA9之间画柱状线
当满足条件背离时,在DEA9和' 背离'位置书写文字
{股票指标网}
STICKLINE(MACD<1日前的MACDAND MACD>0,0,MACD,0.5,0),COLORFF99AA
STICKLINE(MACD<1日前的MACDAND MACD<0,0,MACD,0.5,0), 画蓝色
STICKLINE(MACD>1日前的MACDAND MACD,0,MACD,0.5,0),COLORGRAY
STICKLINE(MACD>1日前的MACDAND MACD>0,0,MACD,0.5,0),画洋红色
DIFF :(收盘价的12日指数移动平均-收盘价的26日指数移动平均)*100/收盘价的26日指数移动平均,画红色
DEA : DIFF9的9日指数移动平均,画红色, 线宽为2
IF(DIFF9<1日前的DIFF9,DIFF9,DRAWNULL),画绿色
IF(DEA9<1日前的DEA9,DEA9,DRAWNULL),画绿色, 线宽为2