通达信优MACD指标公式

 

{标准公式}
{DIF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIF,9);
macd:(DIF-DEA)*2,COLORSTICK;}
{MacD调整参数}
{DIFF:EMA(CLOSE,7)-EMA(CLOSE,19),COLORWHITE;}
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORWHITE;
DEA:EMA(DIFF,9),COLORYELLOW;
MACD:(DIFF-DEA)*2,COLORSTICK;
{牛眼}
MA1:=MA(C,5);
MA2:=MA(C,10);
MA3:=MA(C,20);
MA6:=MA(C,30);
MA4:=MA(C,40);
MA5:=MA(C,60);
牛眼:(MA1>REF(MA1,1) AND C>MA2 AND C>MA5 AND MA1>MA5 AND MA2>MA5
AND crOSS(MA1,MA2) AND DIFF>REF(DIFF,1) AND MA5>REF(MA5,1) AND MA4>REF(MA4,1)
AND MA5>REF(MA5,2) AND V>REF(V,1)*1.6),NODRAW,COLORYELLOW;
{JCCOUNT:=COUNT(CROSS(DIFF,DEA),BArslAST(DEA>=0));
牛眼:=CROSS(DIFF,DEA) AND DEA<0 AND V>REF(V,1)*2) AND COUNT(JCCOUNT=N,22)=1;}
{画图标}
DRAWICON(牛眼,-0.01,38);
DRAWTEXT(牛眼,-0.02,'牛眼'),COLORYELLOW;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
A2:=BARSLAST(REF(CROSS("kdj.K"(9,3,3),"kdJ.D"(9,3,3)),1));
B2:=REF(C,A2+1)>C AND REF("KDJ.K"(9,3,3),A2+1)<"KDJ.K"(9,3,3) AND CROSS
("KDJ.K"(9,3,3),"KDJ.D"(9,3,3));
A3:=BARSLAST(REF(CROSS("rsi.RSI1"(6,12,24),"RSI.RSI2"(6,12,24)),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) AND
CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
C2:=BARSLAST(REF(CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3)),1));
D2:=REF(C,C2+1)<C AND REF("KDJ.K"(9,3,3),C2+1)>"KDJ.K"(9,3,3) AND CROSS
("KDJ.D"(9,3,3),"KDJ.K"(9,3,3));
C3:=BARSLAST(REF(CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24)),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(6,12,24),C3+1)>"RSI.RSI1"(6,12,24) AND
CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24));
{指标底背标示}
{MACD底背:IF(B1>0,-0.1,0),COLORRED,POINTDOT;}
KDJ底背:IF(B2>0,-0.1,0),COLORFF00FF,POINTDOT;
RSI底背:IF(B3>0,-0.1,0),COLORYELLOW,POINTDOT;
{STICKLINE(B1>0,-0.1,0,2,0),COLORRED;}
STICKLINE(B2>0,-0.1,0,1,0),COLORFF00FF;
STICKLINE(B3>0,-0.1,0,1,0),COLORYELLOW;
{指标顶背标示}
{MACD顶背:IF(D1>0,0.1,0),COLOR00FF00,POINTDOT;}
KDJ顶背:IF(D2>0,0.1,0),COLORFFCC66,POINTDOT;
RSI顶背:IF(D3>0,0.1,0),COLORWHITE,POINTDOT;
{STICKLINE(D1>0,0.1,0,2,0),COLOR00FF00;}
STICKLINE(D2>0,0.1,0,1,0),COLORFFCC66;
STICKLINE(D3>0,0.1,0,1,0),COLORWHITE;
{画图标}
{DRAWICON(D2>0,0,2);
DRAWICON(D3>0,0,2);}
{画变色线}
{STICKLINE(MACD>REF(MACD,1) AND MACD>0,0,MACD,0,0),COLORRED;
STICKLINE(MACD<=REF(MACD,1) AND MACD>0,0,MACD,0,0),COLORYELLOW;
STICKLINE(MACD<REF(MACD,1) AND MACD<0,0,MACD,0,0),COLORCYAN;
STICKLINE(MACD>=REF(MACD,1) AND MACD<0,0,MACD,0,0),COLORMAGENTA;
STICKLINE(C>0,0,0,50,1),COLORBLUE;
NOTEXT强:IF(DIFF>MA(DIFF,2),DIFF,DRAWNULL),COLORRED;
NOTEXT弱:IF(DEA>MA(DEA,2),DEA,DRAWNULL),COLORMAGENTA;}
{VARA1:=(Dvol/C)/2,NODRAW;
VARA2:=SUM(IF(VARA1>100 AND CLOSE>REF(CLOSE,1),VARA1,0),0);
VARA3:=SUM(IF(VARA1>100 AND CLOSE<REF(CLOSE,1),VARA1,0),0);
VARA4:=SUM(IF(VARA1<100 AND CLOSE>REF(CLOSE,1),VARA1,0),0);
VARA5:=SUM(IF(VARA1<100 AND CLOSE<REF(CLOSE,1),VARA1,0),0);
VARA6:=VARA2+VARA3+VARA4+VARA5;
机买:=(VARA2/VARA6)*100,LINETHICK2,COLORRED;
机卖:=(VARA3/VARA6)*100,LINETHICK2,COLORGREEN;
主力差:=机买-机卖,LINETHICK2,NODRAW;
强度:主力差-REF(主力差,1),NODRAW,COLORYELLOW;
STICKLINE(强度>1.5,-0.1,0,2,0),COLORYELLOW;
近期:BARSLAST(强度>1.5),NODRAW,COLORGRAY;}
低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
{STICKLINE(低位金叉,0,-0.18,2,0),COLORYELLOW;}
{DRAWTEXT(低位金叉,DEA-0.02,' 低位金叉'),COLORYELLOW;}
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
{STICKLINE(二次金叉,0,-0.18,2,0),COLORFF00FF;}
{DRAWICON(二次金叉,DEA*0.02,13); }
DRAWTEXT(二次金叉,DEA-0.03,' 二次金叉'),COLORWHITE;
{自动画线}
AB1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=REF(CLOSE,AB1+1)>CLOSE AND DIFF>REF(DIFF,AB1+1) AND CROSS(DIFF,DEA);
{STICKLINE(底背离,0,0.13,2,0),COLOR00FF00;}
DRAWLINE(AB1=0,DEA,底背离,DEA,0),COLORRED,DOTLINE,LINETHICK1;
DRAWTEXT(底背离,DEA+0.05,' 底背离'),COLORRED;
AB2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=REF(CLOSE,AB2+1)<CLOSE AND REF(DIFF,AB2+1)>DIFF AND CROSS(DEA,DIFF);
DRAWLINE(AB2=0,DEA,顶背离,DEA,0),COLORGREEN,DOTLINE,LINETHICK1;
DRAWTEXT(顶背离,DEA-0.02,' 顶背离'),COLORLIGREEN;
{N:=7{2,100}
{M:=5{2,100}
{VAR1:=(CLOSE-LLV(LOW,60))/(HHV(HIGH,60)-LLV(LOW,60))*80;
B:=SMA(VAR1,N,1);
VAR2:=SMA(B,M,1);
短买:CROSS(B,VAR2) AND B<40,NODRAW,COLORRED;
DRAWICON(短买,0,11);};
{高送转提示}
DRAWTEXT_FIX(1,0.00,0,0,'送转分红:'),COLORGRAY;
DRAWTEXT_FIX(1,0.10,0,0,EXTERNSTR(0,11)),COLORLIGRAY;
N:=BARSLAST(CROSS(DEA,0));
VAR1:=LLV(DEA,N-2)>0 AND SUM(IF(REF(CROSS(DEA,DIFF),1),1,0),N)=0 AND CROSS
(DEA,DIFF);
N1:=BARSLAST(VAR1);
VAR2:=LLV(DEA,N-2)>0 AND SUM(IF(REF(CROSS(DEA,DIFF),1),1,0),N)=1 AND CROSS
(DEA,DIFF);
N2:=BARSLAST(VAR2);
减持:=VAR2 AND REF(DEA,N2+1)>REF(DEA,N1+1);
大减:=VAR2 AND REF(DEA,N2+1)<REF(DEA,N1+1) AND REF(C,N2+1)<REF(C,N1+1);
清仓:=VAR2 AND REF(DEA,N2+1)<REF(DEA,N1+1) AND REF(C,N2+1)>REF(C,N1+1);
BB1:=减持 OR 大减 OR 清仓;
DRAWTEXT(减持,DEA+0.02,'减持'),COLORGREEN;
DRAWTEXT(大减,DEA+0.02,'大减'),COLORCYAN;
DRAWTEXT(清仓,DEA+0.02,'清仓');
小N:BARSLAST(BB1),NODRAW;
YQXC:=SUM(IF(CROSS(0,DEA),1,0),小N)=1;
NN:BARSLAST(CROSS(0,DEA)),NODRAW;
VARB1:=HHV(DEA,NN-2)<0 AND SUM(IF(REF(CROSS(DIFF,DEA),1),1,0),NN)=0 AND CROSS
(DIFF,DEA);
NN1:BARSLAST(VARB1),NODRAW;
VARB2:=HHV(DEA,NN-2)<0 AND SUM(IF(REF(CROSS(DIFF,DEA),1),1,0),NN)=1 AND CROSS
(DIFF,DEA);
NN2:BARSLAST(VARB2),NODRAW;
增持:=VARB1 AND YQXC=1;
全仓:=VARB2 AND REF(DEA,NN2+1)>REF(DEA,NN1+1) AND YQXC=1;
开仓:=IF(全仓,0,VARB2 AND REF(DEA,NN2+1)>REF(DEA,NN1+1));
DRAWTEXT(增持,DEA-0.05,'增持'),COLORRED;
DRAWTEXT(全仓,DEA-0.05,'全仓'),COLORMAGENTA;
DRAWTEXT(开仓,DEA-0.05,'开仓'),COLORYELLOW;




来函数检测结果如下
该公式没有未来函数


解密、定制、编写公式指标请联系QQ或微信同号:88652583
置顶指标

相关指标公式

输出DIFF:收盘价的12日指数移动平均-收盘价的26日指数移动平均,画白色
输出DEA:DIFF的9日指数移动平均,画黄色
输出平滑异同平均线:(DIFF-DEA)*2,COLORSTICK
MA1赋值:收盘价的5日简单移动平均
MA2赋值:收盘价的10日简单移动平均
MA3赋值:收盘价的20日简单移动平均
MA6赋值:收盘价的30日简单移动平均
MA4赋值:收盘价的40日简单移动平均
MA5赋值:收盘价的60日简单移动平均
输出牛眼:(MA1>1日前的MA1 AND 收盘价>MA2 AND 收盘价>MA5 AND MA1>MA5 AND MA2>MA5AND MA1上穿MA2 AND DIFF>1日前的DIFF AND MA5>1日前的MA5 AND MA4>1日前的MA4AND MA5>2日前的MA5 AND 成交量(手)>1日前的成交量(手)*1.6),NODRAW,画黄色
当满足条件牛眼时,在-0.01位置画38号图标
当满足条件牛眼时,在-0.02位置书写文字,画黄色
A1赋值:上次1日前的DIFF上穿DEA距今天数
B1赋值:A1+1日前的收盘价>收盘价 AND A1+1日前的DIFFA2赋值:上次1日前的"KDJ的K"(9,3,3)上穿"KDJ的D"(9,3,3)距今天数
B2赋值:A2+1日前的收盘价>收盘价 AND A2+1日前的"KDJ的K"(9,3,3)<"KDJ的K"(9,3,3) AND "KDJ的K"(9,3,3)上穿"KDJ的D"(9,3,3)
A3赋值:上次1日前的"RSI的RSI1"(6,12,24)上穿"RSI的RSI2"(6,12,24)距今天数
B3赋值:A3+1日前的收盘价>收盘价 AND A3+1日前的"RSI的RSI1"(6,12,24)<"RSI的RSI1"(6,12,24) ANDCROSS("RSI的RSI1"(6,12,24),"RSI的RSI2"(6,12,24))
C1赋值:上次1日前的DEA上穿DIFF距今天数
D1赋值:C1+1日前的收盘价<收盘价 AND C1+1日前的DIFF>DIFF AND DEA上穿DIFF
C2赋值:上次1日前的"KDJ的D"(9,3,3)上穿"KDJ的K"(9,3,3)距今天数
D2赋值:C2+1日前的收盘价<收盘价 AND C2+1日前的"KDJ的K"(9,3,3)>"KDJ的K"(9,3,3) AND "KDJ的D"(9,3,3)上穿"KDJ的K"(9,3,3)
C3赋值:上次1日前的"RSI的RSI2"(6,12,24)上穿"RSI的RSI1"(6,12,24)距今天数
D3赋值:C3+1日前的收盘价<收盘价 AND C3+1日前的"RSI的RSI1"(6,12,24)>"RSI的RSI1"(6,12,24) ANDCROSS("RSI的RSI2"(6,12,24),"RSI的RSI1"(6,12,24))
输出KDJ底背:如果B2>0,返回-0.1,否则返回0,COLORFF00FF,POINTDOT
输出RSI底背:如果B3>0,返回-0.1,否则返回0,画黄色,POINTDOT
当满足条件B2>0时,在-0.1和0位置之间画柱状线,宽度为1,0不为0则画空心柱.,COLORFF00FF
当满足条件B3>0时,在-0.1和0位置之间画柱状线,宽度为1,0不为0则画空心柱.,画黄色
输出KDJ顶背:如果D2>0,返回0.1,否则返回0,COLORFFCC66,POINTDOT
输出RSI顶背:如果D3>0,返回0.1,否则返回0,画白色,POINTDOT
当满足条件D2>0时,在0.1和0位置之间画柱状线,宽度为1,0不为0则画空心柱.,COLORFFCC66
当满足条件D3>0时,在0.1和0位置之间画柱状线,宽度为1,0不为0则画空心柱.,画白色
低位金叉赋值:DIFF上穿DEA AND DIFF<-0.1
JCCOUNT赋值:统计上次DEA>=0距今天数日中满足DIFF上穿DEA的天数
二次金叉赋值:DIFF上穿DEA AND DEA<0 AND 统计21日中满足JCCOUNT=2的天数=1
当满足条件二次金叉时,在DEA-0.03位置书写文字,画白色
AB1赋值:上次1日前的DIFF上穿DEA距今天数
底背离赋值:AB1+1日前的收盘价>收盘价 AND DIFF>AB1+1日前的DIFF AND DIFF上穿DEA
当满足条件AB1=0时,在DEA位置画直线起点,当满足条件底背离时,在DEA位置画直线终点,0表示是否延长.,画红色,DOTLINE,线宽为1
当满足条件底背离时,在DEA+0.05位置书写文字,画红色
AB2赋值:上次1日前的DEA上穿DIFF距今天数
顶背离赋值:AB2+1日前的收盘价<收盘价 AND AB2+1日前的DIFF>DIFF AND DEA上穿DIFF
当满足条件AB2=0时,在DEA位置画直线起点,当满足条件顶背离时,在DEA位置画直线终点,0表示是否延长.,画绿色,DOTLINE,线宽为1
当满足条件顶背离时,在DEA-0.02位置书写文字,画淡绿色

当满足条件1时,在横轴0.00纵轴0位置书写文字,画深灰色
当满足条件1时,在横轴0.10纵轴0位置书写文字,画淡灰色
N赋值:上次DEA上穿0距今天数
VAR1赋值:N-2日内DEA的最低值>0 AND 如果1日前的DEA上穿DIFF,返回1,否则返回0的N日累和=0 AND DEA上穿DIFF
N1赋值:上次VAR1距今天数
VAR2赋值:N-2日内DEA的最低值>0 AND 如果1日前的DEA上穿DIFF,返回1,否则返回0的N日累和=1 AND DEA上穿DIFF
N2赋值:上次VAR2距今天数
减持赋值:VAR2 AND N2+1日前的DEA>N1+1日前的DEA
大减赋值:VAR2 AND N2+1日前的DEA清仓赋值:VAR2 AND N2+1日前的DEAN1+1日前的收盘价
BB1赋值:减持 OR 大减 OR 清仓
当满足条件减持时,在DEA+0.02位置书写文字,画绿色
当满足条件大减时,在DEA+0.02位置书写文字,画青色
当满足条件清仓时,在DEA+0.02位置书写文字
输出小N:上次BB1距今天数,NODRAW
YQXC赋值:如果0上穿DEA,返回1,否则返回0的小N日累和=1
输出NN:上次0上穿DEA距今天数,NODRAW
VARB1赋值:NN-2日内DEA的最高值<0 AND 如果1日前的DIFF上穿DEA,返回1,否则返回0的NN日累和=0 AND DIFF上穿DEA
输出NN1:上次VARB1距今天数,NODRAW
VARB2赋值:NN-2日内DEA的最高值<0 AND 如果1日前的DIFF上穿DEA,返回1,否则返回0的NN日累和=1 AND DIFF上穿DEA
输出NN2:上次VARB2距今天数,NODRAW
增持赋值:VARB1 AND YQXC=1
全仓赋值:VARB2 AND NN2+1日前的DEA>NN1+1日前的DEA AND YQXC=1
开仓赋值:如果全仓,返回0,否则返回VARB2ANDREF(DEA,NN2+1)>NN1+1日前的DEA
当满足条件增持时,在DEA-0.05位置书写文字,画红色
当满足条件全仓时,在DEA-0.05位置书写文字,画洋红色
当满足条件开仓时,在DEA-0.05位置书写文字,画黄色

指标安装下载帮助  |   联系我们  |  乐淘公式网  |  公式网   |  指标公式  |   加入收藏   |  设为主页

@2005-2025 浙ICP备2024071487号-1 乐淘公式网公式网均来源互联网收集整理,如不慎侵犯了你的权益,请联系我们告知,我们将做删除处理
免责声明:乐淘公式网所有指标公式及文章由网络收集,不保障实时性和真实性, 仅供学习研究并不构成投资建议,请勿以此为依据进行股票交易,由此引起的投资亏损与本站无关。
QQ:88652583 微信 88652583
sitemap站点地图