其实这个指标早就在论坛发过很多,旧饭重炒的目的,是想帮助一些初学者掌握一种方法,共同学习!在另一论坛有同学专门短信要求写,因为也在此巾出来,共勉!!
MACD主图叠加指标,在这里我只写飞狐的
一方案,将MACD放在主图上方
C/C++ Code复制内容到剪贴板
- DIFZ:=EMA(C,12)-EMA(C,26);
- DEAZ:=EMA(DIFZ,9);
- MACDZ:=5*(DIFZ-DEAZ);
-
-
- N1:=SYSPARAM(3);
- NN:=N1-SYSPARAM(2)+1;
- HH:=HHV(C,NN);
- LL:=LLV(C,NN);
- 最高:=HH[N1];
- 最低:=LL[N1];
- RCC:=最高*1.05-(最高*1.05-最低*1)*0.1;
- 限制显示K线面积:=RANGE(BARPOS,SYSPARAM(3)-120,SYSPARAM(3)+1);
- FILLRGN(DIFZ>DEAZ AND 限制显示K线面积,DIFZ*5/2+RCC,EMA(DIFZ*5/2+RCC,9)),COLORFF0080;
- FILLRGN(DIFZ<=DEAZ AND 限制显示K线面积,DIFZ*5/2+RCC,EMA(DIFZ*5/2+RCC,9)),COLORGRAY;
- {以上是DIFF/DEA画色带}
- STICKLINE((RCC+MACDZ)>RCC AND (RCC+MACDZ)<=REF(RCC+MACDZ,1) AND 限制显示K线面积,RCC,RCC+MACDZ,5,0),COLOR400080;
- STICKLINE((RCC+MACDZ)>RCC AND (RCC+MACDZ)>REF(RCC+MACDZ,1) AND 限制显示K线面积,RCC,RCC+MACDZ,5,0),COLOR00FFFF;
- STICKLINE((RCC+MACDZ)<=RCC AND (RCC+MACDZ)<=REF(RCC+MACDZ,1) AND 限制显示K线面积,RCC,RCC+MACDZ,5,0),COLOR008080;
- STICKLINE((RCC+MACDZ)<=RCC AND (RCC+MACDZ)>REF(RCC+MACDZ,1) AND 限制显示K线面积,RCC,RCC+MACDZ,5,0),COLORC080FF;
- {以上显示柱子}
- PARTLINE(限制显示K线面积,EMA(DIFZ*5/2+RCC,9)),COLORFFFFFF,LINETHICK1,PRECISION2;
- PARTLINE(限制显示K线面积,DIFZ*5/2+RCC),COLORRED,LINETHICK1,PRECISION2;
- PARTLINE((DIFZ*5/2+RCC)<=REF(DIFZ*5/2+RCC,1) AND 限制显示K线面积,DIFZ*5/2+RCC),COLORFFF000,LINETHICK1,PRECISION2;
- {以上是显示DIFF和DEA}
-
- {显示K线,以免被色带盖住}
- STICKLINE(C>O,H,L,0.1,1),COLORRED;
- STICKLINE(C>O,C,O,8,1),COLORRED;
- STICKLINE(C<=O,H,L,0.1,1),COLORCYAN;
- STICKLINE(C<=O,C,O,8,1),COLORCYAN;
-
- {均线状态}
- MA5:MA(C,5);
- MA10:MA(C,10);
- MA20:MA(C,20);
- MA30:MA(C,30);
- MA60:MA(C,60);