【通达信源码分享】很有特色日周MACD同图显示指标公式源码
【参数使用说明】:参数的调节是把日周两个MACD指标分开,避免重叠。如有重叠,可调整参数。
【调整参数方法】:可使用快捷键Alt+T来调整,从重叠那天算起到最后的天数是多少(计算方法:鼠标点出光标后,先放到在重叠处,按一下键盘的空格键,然后移动到最后的K线位置,再按一下空格键,就会出现小窗口,小窗口上会有区间的交易天数),然后把参数调整到大于这个天数的数据即可。
公式源码:
周放大数:=0.8;
日缩小数:=1;
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
QJZXZ:=CONST(MIN(CONST(LLV(DIF,下移周期)),CONST(LLV(MACD,下移周期))));
DRAWGBK(C>1,RGB(0,0,0),RGB(1,1,1),1,0,0);
{====================MACD过前高=======================}
QGZSJ1:=BARSLAST(CROSS(0,MACD));
QGZSJ2:=IF(MACD<0 AND ISLASTBAR,SUMBARS(CROSS(MACD,0),1),SUMBARS(CROSS(MACD,0),2));
ZDZ:=CONST(FINDHIGH(MACD,QGZSJ1,QGZSJ2-QGZSJ1,1));
ZDZSJ:=CONST(FINDHIGHBARS(MACD,QGZSJ1,QGZSJ2-QGZSJ1,1));
HX:=DRAWLINE(ZDZ=MACD,MACD,REF(ZDZ=MACD,1),REF(MACD,1),1);
NOTEXTQ22:IF(CURRBARSCOUNT<=ZDZSJ+1,HX,DRAWNULL),COLORYELLOW,DOTLINE;
NOTEXTQ23:IF(CURRBARSCOUNT<=ZDZSJ+1,NOTEXTQ22*1.38,DRAWNULL),COLORBLACK,POINTDOT;
DRAWTEXT(ISLASTBAR,NOTEXTQ22,STRCAT(' ',CON2STR(NOTEXTQ22,2))),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=ZDZSJ+1,MACD,'前横线'),COLORYELLOW,DRAWABOVE;
{=====================================================}
SCSJ:=CONST(BARSLAST(DIF<REF(DIF,1) AND REF(DIF,1)>REF(DIF,2)))+1;
NOTEXTSCHX:IF(CURRBARSCOUNT<=SCSJ+1,CONST(REF(DIF,SCSJ)),DRAWNULL),COLORGREEN,DOTLINE;
DRAWICON(CROSS(DIF,NOTEXTSCHX),NOTEXTSCHX,1);
{=============================}
日DIF:DIF,COLORWHITE,NODRAW;
日DEA:DEA,COLORMAGENTA,NODRAW;
日MACD:MACD,COLORRED,NODRAW;
STICKLINE(日MACD>0,日MACD*日缩小数,0,0,0),COLORRED;
STICKLINE(日MACD<0,日MACD*日缩小数,0,0,0),COLORCYAN;
NOTEXTDIF:日DIF*日缩小数,COLORWHITE;
NOTEXTDEA:日DEA*日缩小数,COLORMAGENTA;
{=============================}
下移线1:=0.1;
周DIF:EMA(CLOSE,12*5)-EMA(CLOSE,26*5),COLORWHITE,NODRAW;
周DEA:EMA(周DIF,9*5),COLORMAGENTA,NODRAW;
周MACD:(周DIF-周DEA)*2,COLORRED,NODRAW;
MACD转换1:=周MACD*周放大数+下移线1;
T22:=周DIF*周放大数+下移线1;
QJZDZ:=CONST(MAX(CONST(HHV(T22,下移周期)),CONST(HHV(MACD转换1,下移周期))));
{=============================}
下移线2:=-(ABS(QJZXZ)+ABS(QJZDZ));
{=============================}
MACD转换2:=周MACD*周放大数+下移线2;
STICKLINE(周MACD>0,MACD转换2,下移线2,0,1),COLORRED;
STICKLINE(周MACD<0,MACD转换2,下移线2,0,1),COLORCYAN;
NOTEXT22:周DIF*周放大数+下移线2,COLORMAGENTA;
NOTEXT33:周DEA*周放大数+下移线2,COLORWHITE;
DRAWTEXT_FIX(1,0,0,0,'███████'),COLORYELLOW;
DRAWTEXT_FIX(1,0,0,0,' 日线MACD'),COLORRED;
DRAWTEXT_FIX(1,0,0.53,0,'███████'),COLORYELLOW;
DRAWTEXT_FIX(1,0,0.53,0,' 周线MACD'),COLORRED;
版权声明
本文版权归掌上指标所有。
未经许可,不得转载,转载请注明出处!