BIG_MACD
一.介绍
- 原理:
MACD是基于BIAS乘离率的变形应用。它是利用两条不同速度的指数平滑移动平均线来计算的(其中一条变动速度快–短期的移动平均线,另一条较慢—长期的移动平均线),两者之间的差异状况(DIF)作为研判行情的基础,然后再求DIF的9日平滑移动平均线,即为DEA线。而MACD实际就是运用快速与慢速移动平均线聚合与分离的征兆,来研判买进与卖出的时机。 相关字母与标号:
- EMA:指数平滑移动平均线
- N:周期
- DIF:乘离率
- DEA:离差平均值
计算方法:
- DIF:EMA(C,short) - EMA(C, long);
- DEA: EMA(DIF, M)
- MACD: 2*(DIF-DEA)
基本应用原则:
- DIF与DEA均为正值时,为多头行情
- DIF与DEA均为负值时,为空头行情
- DIF向上突破DEA时,可买入
- DIF向下突破DEA时,可卖出
四.代码:
DIFF:EMA(DCLOSE,12)-EMA(DCLOSE,26);
DEA:EMA(DIFF,9),COLORFFFF00;
MACD:(DIFF-DEA)*2;
STICKLINE(MACD>=0 AND MACD>=REF(MACD,1),0,MACD,1,0),colorred;
STICKLINE(MACD>=0 AND MACD<=REF(MACD,1),0,MACD,1,0),colorgreen;
STICKLINE(MACD<=0 AND MACD>=REF(MACD,1),0,MACD,1,0),COLORFF00FF;
STICKLINE(MACD<=0 AND MACD<=REF(MACD,1),0,MACD,1,0),COLOR00FFFF;
多转空:=((((LLV(MACD,4)>0) AND (MACD<REF(MACD,1))) AND (REF(MACD,1)>REF(MACD,2))) AND (REF(MACD,2)>REF(MACD,3)));
空转多:=((((HHV(MACD,4)<0) AND (MACD>REF(MACD,1))) AND (REF(MACD,1)<REF(MACD,2))) AND (REF(MACD,2)<REF(MACD,3)));
DRAWICON(多转空,MACD,2);
DRAWICON(空转多,MACD,1);
低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
DRAWICON(低位金叉,DEA,1);
DRAWTEXT(低位金叉,DEA,‘低位金叉‘),COLORFF00FF;
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
DRAWICON(二次金叉,DEA*1.06,1);
STICKLINE(二次金叉,0,0.2,2,0),COLORFF00FF;
DRAWTEXT(二次金叉,DEA*1.06,‘二次金叉‘),colorred;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA);
DRAWTEXT(底背离,-0.2-MACD,‘底背离‘),colorwhite;
DRAWICON(底背离,-0.2-MACD,1);
A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF);
DRAWICON(顶背离,0.2+MACD,2);
DRAWTEXT(顶背离,0.2+MACD,‘顶背离‘),colorwhite;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。