此公式以MACD指标为基础,通过计算短期与长期的指数移动平均线(EMA)差异,衍生出DIF和DEA两个核心指标。进一步地,公式引入了变格和DIF转折点的概念,通过精确的数学模型,预测MACD可能出现的转折点,为交易者提供了更为深入的动量分析工具。
公式通过变格与DIF转折点的比较,生成了上拐和下拐信号,分别以红色和绿色的线条在图表上表示,直观地指示了可能的买入和卖出时机。同时,通过STICKLINE函数,将交易信号与K线图相结合,增强了信号的可视化效果,使交易者能够快速识别市场趋势的变化。
公式源码如下:
SHORT:=12;
LONG:=26;
M:=12;
DIF:=EMA(CLOSE,SHORT)-EMA(CLOSE,LONG);
DEA:=EMA(DIF,M);
macd:=2*(DIF-DEA);
KK:=IF(DIF>DEA,5,-5);
JCSC:=(M-1)/(M+1)*DEA/(1-2/(M+1));
DD:=(MACD/2+(DEA*(M-1)/(M+1)))/(1-2/(M+1));
DIF转折点:=(DIF*(SHORT+1)*(LONG+1)-(LONG+1)*(SHORT-1)*EMA(C,SHORT)+(SHORT+1)*(LONG-1)*EMA(C,LONG))/(2*((LONG+1)-(SHORT+1)))COLORGREEN,POINTDOT;
金死叉价:=(JCSC*(SHORT+1)*(LONG+1)-(LONG+1)*(SHORT-1)*EMA(C,SHORT)+(SHORT+1)*(LONG-1)*EMA(C,LONG))/(2*((LONG+1)-(SHORT+1))),NODRAW;
变格:=(DD*(SHORT+1)*(LONG+1)-(LONG+1)*(SHORT-1)*EMA(C,SHORT)+(SHORT+1)*(LONG-1)*EMA(C,LONG))/(2*((LONG+1)-(SHORT+1))),COLORYELLOW,POINTDOT;
顶参考:=IF(变格>=DIF转折点,变格,DRAWNULL),COLORYELLOW,CIRCLEDOT,LINETHICK1;
TY:=H;
上拐:IF(DIF转折点< 变格,DIF转折点,DRAWNULL),COLORRED,LINETHICK4;
下拐:IF(DIF转折点>=变格,DIF转折点,DRAWNULL),COLOR33FF33,POINTDOT,LINETHICK4;
ZJ:=上拐,COLOR0000FF;
HY:=金死叉价,COLORFF00FF;
IF(ZJ>REF(ZJ,1),ZJ,DRAWNULL),COLORRED,LINETHICK2;
IF(HY>REF(HY,1),HY,DRAWNULL),COLORMAGENTA,LINETHICK2,NODRAW;
IF(HY< REF(HY,1),HY,DRAWNULL),COLORBLUE,LINETHICK2,NODRAW;
STICKLINE(C>ZJ AND C>O,H,C,0,0 ),COLORRED;
STICKLINE(C>ZJ AND C>O,L,O,0,0 ),COLORRED;
STICKLINE(C>ZJ AND C>O,O,C,2.8,1),COLORRED;
STICKLINE(C>ZJ AND C<=O,H,L,0,0 ),COLORRED;
STICKLINE(C>ZJ AND C<=O,O,C,2.8,0),COLORRED;
STICKLINE(CLOSE=ZJ,H,L,3,0),COLORWHITE;
STICKLINE(CLOSE< ZJ,H,L,0,0),COLORYELLOW;
STICKLINE(CLOSE< ZJ,O,C,2.5,0),COLORYELLOW;
STICKLINE(C< HY AND C>O,H,C,0,0),COLORCYAN;
STICKLINE(C< HY AND C>O,O,L,0,0),COLORCYAN;
STICKLINE(C< HY AND C>O,O,C,2.8,1),COLORCYAN;
STICKLINE(C< HY AND C<=O,H,L,0,0),COLORCYAN;
STICKLINE(C< HY AND C<=O,O,C,2.8,0),COLORCYAN;
HD0:=crOSS(DIF,DEA);
买入准备:DRAWICON(CROSS(变格,DIF转折点),上拐,34);
卖出准备:DRAWICON(CROSS(DIF转折点,变格),下拐,35);
SBL:=STRCAT(STRCAT(STRCAT(STRCAT(DYBLOCK,HYBLOCK),FGBLOCK),GNBLOCK),ZDBLOCK);
DRAWTEXT_FIX(ISLASTBAR,0.01,0.005,0,SBL),COLORCYAN;
公式中的买入准备和卖出准备信号,通过图标的形式,为交易者提供了明确的交易决策辅助。当变格上穿DIF转折点时,显示买入准备图标;当DIF转折点下穿变格时,显示卖出准备图标。这些信号的生成,结合了MACD的动量分析与价格行为,提高了交易信号的实用性和准确性。
最后,公式通过DRAWTEXT_FIX函数,将市场的重要信息如DYBLOCK、HYBLOCK、FGBLOCK、GNBLOCK和ZDBLOCK等综合展示在图表上,为交易者提供了全面的市场背景信息。这种综合信息的展示,帮助交易者在做出交易决策时,能够考虑到更多的市场因素,从而提高交易的成功率。