相关简介:通达信macd背离选股(画线)指标公式源码分享

     通达信指标公式源码概况:

  指标类别:通达信指标公式

  授权方式:免费版

  指标评级:★★★★★

  指标分类:策略

  画线方法:副图

   在通达信行情软件中,自带了80多个选股公式,如果我们用好这些公式,对我们选股会有较大的帮助,起到事半功倍的效果。由于一些股友不理解这些公式的含义,因此一般也不怎么用。今后我们逐步讲解这些公式的含义供股友们参考。

   macd买入点条件选股:就是DIFF上穿DEA或者说MacD金叉,是通达信自带的公式之一。

通达信指标公式源码:

   input:p(12,1,100),s(26,1,100),m(9,1,50),N(0,0,1);

   周MACD:=”MACD.MACD#WEEK”;

   STICKLINE(周MACD>=0ANDDATATYPE=8,0,周MACD,11,0),Color000055;

   STICKLINE(周MACD<0ANDDATATYPE=8,0,周MACD,11,0),Color515100;

   DIFF:(EMA(CLOSE,P)-EMA(CLOSE,S)),LINETHICK1;

   DEA:EMA(DIFF,M),Color1AFFFF,LINETHICK1,LAYER0;

   macd:(diff-dea)*2,COLORRED,LINETHICK0;

   PARTLINE(DIFF,DIFF>=REF(DIFF,1),RGB(200,0,200),DIFF<REF(DIFF,1),RGB(0,200,200)),LAYER0;;

   STICKLINE(macd>0andmacd>=REF(macd,1),macd,0,4,0),Color0000F2;

   STICKLINE(macd>0andmacd<REF(macd,1),macd,0,4,1),Color0000F2;

   STICKLINE(macd<0andmacd<REF(macd,1),macd,0,4,0),Color008000;

   STICKLINE(macd<0andmacd>=REF(macd,1),macd,0,4,1),Color008000;

   ES:=IF(N=0,REF(EMA(C,S),1),EMA(C,S));

   EP:=IF(N=0,REF(EMA(C,P),1),EMA(C,P));

   DI:=IF(N=0,REF(DIFF,1),DIFF);

   零度价:=((P+1)*(S-1)*ES-(S+1)*(P-1)*EP)/(2*(S+1)-2*(P+1));

   IFN=0ANDREF(DIFF,1)<0andbarstatus=2THENBEGINDRAWTEXTREL(5,10,’DIFF上穿零度对应的股价:’+NUMTOSTRN(零度价,2)+’元’),COLOR00D0D0;END;

   IFN=1ANDDIFF<0andbarstatus=2THENBEGINDRAWTEXTREL(5,10,’DIFF上穿零度对应的股价:’+NUMTOSTRN(零度价,2)+’元’),COLOR00D0D0;END;

   IFN=0ANDREF(DIFF,1)>0andbarstatus=2THENBEGINDRAWTEXTREL(5,10,’DIFF下穿零度对应的股价:’+NUMTOSTRN(零度价,2)+’元’),COLORD0D0D0;END;

   IFN=1ANDDIFF>0andbarstatus=2THENBEGINDRAWTEXTREL(5,10,’DIFF下穿零度对应的股价:’+NUMTOSTRN(零度价,2)+’元’),COLORD0D0D0;END;

   拐点价:=((P-1)*EP/(P+1)-(S-1)*ES/(S+1)-DI)*(S+1)*(P+1)/(2*(P+1)-2*(S+1));

   IFN=0ANDREF(DIFF,1)<REF(DIFF,2)andbarstatus=2THENBEGINDRAWTEXTREL(5,80,’DIFF向上拐点对应的股价:’+NUMTOSTRN(拐点价,2)+’元’),COLOR00D0D0;END;

   IFN=1ANDDIFF<REF(DIFF,1)andbarstatus=2THENBEGINDRAWTEXTREL(5,80,’DIFF向上拐点对应的股价:’+NUMTOSTRN(拐点价,2)+’元’),COLOR00D0D0;END;

   IFN=0ANDREF(DIFF,1)>REF(DIFF,2)andbarstatus=2THENBEGINDRAWTEXTREL(5,80,’DIFF向下拐点对应的股价:’+NUMTOSTRN(拐点价,2)+’元’),COLORD0D0D0;END;

   IFN=1ANDDIFF>REF(DIFF,1)andbarstatus=2THENBEGINDRAWTEXTREL(5,80,’DIFF向下拐点对应的股价:’+NUMTOSTRN(拐点价,2)+’元’),COLORD0D0D0;END;

   获利盘:=WINNER(C)*100;

   趋势:=3*SMA((C-LLV(L,27))/(HHV(H,27)-LLV(L,27))*100,5,1)-2*Sma(SMA((C-LLV(L,27))/(HHV(H,27)-LLV(L,27))*100,5,1),3,1);

   动能:=((EMA(C,3)-EMA(C,8)))*100;

   cci:=”CCI”;

   K:=”kd.K”;

   rsi:=”RSI”;

   bias:=”BIAS”;

   A1:=(CCI+250)/5;

   A2:=K*1.15;

   A3:=RSI*1.25;

   A4:=BIAS*7.14;

   A5:=(动能+100)*0.5;

   趋势合成:=(趋势+获利盘+A1+A2+A3+A4+A5)/7;

   Z1:=SMA(趋势合成,10,1);

   Z2:=SMA(Z1,3,1);

   Z3:=SMA(趋势合成,5,3);

   低吸:=FILTER(crOSS(趋势合成,Z3)ANDREF(趋势,1)<=12ANDRSI>REF(RSI,1),3);

   年选股:=SUM(低吸,250);

   四日3%:=HHV(H,3)>REF(C,3)*1.03ANDREF(CROSS(低吸,0.8),2);

   年成功:=SUM(四日3%,250);

   成功率:=(年成功/年选股)*100;

   VARA2:=LLV(MA(LOW,3),3);

   VARA3:=HHV(MA(HIGH,3),3);

   KA:=EMA((CLOSE-VARA2)/(VARA3-VARA2)*100,4);

   DB:=EMA(0.667*REF(KA,1)+0.333*KA,2);

   JJ:=3*KA-2*DB;

   关注:=CROSS(JJ,KA);

   赚钱不难:成功率>50AND低吸=1AND关注=1;

   DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);

   DEA:=EMA(DIFF,9);

   A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));

   B1:=REF(C,A1+1)>CANDREF(DIFF,A1+1)<DIFFANDCROSS(DIFF,DEA);

   A2:=BARSLAST(REF(CROSS(“KDJ.K”(9,3,3),”KDJ.D”(9,3,3)),1));

   B2:=REF(C,A2+1)>CANDREF(“KDJ.K”(9,3,3),A2+1)<“KDJ.K”(9,3,3)ANDCROSS(“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)>CANDREF(“RSI.RSI1″(6,12,24),A3+1)<“RSI.RSI1″(6,12,24)ANDCROSS(“RSI.RSI1″(6,12,24),”RSI.RSI2″(6,12,24));

   底背离:B1>0ORB2>0ORB3>0;

   {集成了MACD、KDJ、RSI三个指标的底背离};

[源码注释]通达信公式动态翻译结果

ZT赋值:如果模糊匹配品种名称ORNAMELIKE(‘*ST’),返回收盘价=计算涨停价,否则返回如果模糊匹配品种代码OR(模糊匹配品种代码ANDDATE>=1200824),返回收盘价=计算涨停价,否则返回收盘价=计算涨停价

T赋值:上次ZT距今天数

输出XG:T>=3 AND T<=6 AND 开盘价<T日前的收盘价 AND 收盘价/1日前的收盘价>1.06

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。