分析家公式网 最经典最实用macd源码汇总

以下是分析家公式网分享的,最经典最实用macd(源码)(无源码的请下载附件导入)
实用MACD
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORFFFFFF;
DEA:EMA(DIFF,9),COLOR00FFFF;
MACD:(2)*(DIFF-DEA),COLORSTICK,COLOR00FF00;
AT1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
BIT1:=(REF(CLOSE,AT1+1)>CLOSE) AND (REF(DIFF,AT1+1)<DIFF) AND CROSS(DIFF,DEA);
DRAWTEXT(IF((BIT1>0),1,0),0.279,’大战役’),COLOR00FFFC;
RSV:=((CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9)))*(100);
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
AT2:=BARSLAST(REF(CROSS(K,D),1));
B2:=(REF(CLOSE,AT2+1)>CLOSE) AND (REF(K,AT2+1)<K) AND CROSS(K,D);
DRAWTEXT(IF((B2>0),1,0),0.233,’瞄准’),COLOR6C8CCF;
LC:=REF(CLOSE,1);
RSI1:=((SMA(MAX(CLOSE-LC,0),6,1))/(SMA(ABS(CLOSE-LC),6,1)))*(100);
RSI2:=((SMA(MAX(CLOSE-LC,0),12,1))/(SMA(ABS(CLOSE-LC),12,1)))*(100);
A3:=BARSLAST(REF(CROSS(RSI1,RSI2),1));
B3:=(REF(CLOSE,A3+1)>CLOSE) AND (REF(RSI1,A3+1)<RSI1) AND CROSS(RSI1,RSI2);
DRAWTEXT(IF((B3>0),1,0),(-0.01),’瞄准’),COLORFF05FF;
SIQ1:=(OPEN<MA(CLOSE,20.5)) AND (CLOSE>MA(CLOSE,20.5));
SIQ2:=(MA(CLOSE,8)<MA(CLOSE,20.5));
SIQ3:=(MA(CLOSE,20.5)<MA(CLOSE,41));
SIQ5:=(VOL>(MA(VOL,5))*(1.01)) AND (VOL>(MA(VOL,10))*(1.01));
SIQ:=SIQ1 AND SIQ2 AND SIQ3 AND SIQ5;
DRAWTEXT(SIQ,0.2,’冲锋’),COLORFF00FF;

分析家公式网 macd公式源码
在股市投资中,MACD指标作为一种技术分析的手段,得到了投资者的认知。但如何使用MACD指标,才能使投资收益达到最佳境界,却是知者甚微。在股市操作中。MACD指标在保护投资者利益方面,远超过它发现投资机会的功效。如何巧用MACD指标.在股海中盈利,分析家公式网给出以下操作建议和解答:
一、MACD标准背离公式和选股公式
MACD指标,终极指标,也就是MACD指标的背离(背驰),是很精确的买卖点,特别是在一分钟和五分钟上的macd背离,实战效果可以说无出其右。
以下的公式源码是个标准版的MACD背离公式源码,很不错,跟系统默认的macd指标一致,而且标出了背离、金叉等,非常好。
利用此公式的操作方法:
收盘后下载数据(同时下载5分钟数据) ,   利用MACD背离选股公式按照5、10、15、30、60分钟分别选股  ,  加入自选,实盘择优买入,选股的次级别(当然也包括同级别或最小的一分钟级别)顶背离后短线离场,这样基本可以有赚不赔!
1、 MACD标准背驰公式源码如下:
DIFF:EMA(CLOSE,12)-EMA(CLOSE,27);
DEA:EMA(DIFF,9);
MACD:2*(DIFF-DEA), COLORSTICK,LINETHICK2;
低位金叉:=CROSS(DIFF,DEA) AND DIFF<>
STICKLINE(低位金叉,0,0.08,6,0),COLORYELLOW;
DRAWTEXT(低位金叉,0.16,’ 低位金叉’),COLORWHITE;
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIFF,DEA) AND DEA<0 and=”” count(jccount=””>
STICKLINE(二次金叉,0,0.06,6,0),COLORFF00FF;
DRAWICON(二次金叉,DEA*0.9,1) ;
DRAWTEXT(二次金叉,0.2,’ 二次金叉’),COLORYELLOW;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=REF(CLOSE,A1 1)>CLOSE AND DIFF>REF(DIFF,A1 1) AND CROSS(DIFF,DEA);
STICKLINE(底背离,0,0.03,6,0),COLOR00FF00;
底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK4;
DRAWTEXT(底背离,0.12,’ 底背离’),COLORFF00FF;
A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=REF(CLOSE,A2 1)DIFF AND CROSS(DEA,DIFF);
顶背:DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORGREEN,LINETHICK4;
DRAWTEXT(低位金叉 AND 二次金叉 AND 底背离,0.25,’三全项’),COLOR0000FF,LINETHICK2;
2、MACD标准背驰选股公式:
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:REF(CLOSE,A1 1)>CLOSE AND DIFF>REF(DIFF,A1 1) AND CROSS(DIFF,DEA);
3、MACD标准背驰选股公式:
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD0:=(DIF-DEA)*2;
MJ:=MACD0;
S05:=SUM(MJ,0);
QST:=BARSLAST(MJ<0 and=”” ref(mj,1)=””>0) 1;
QXT:=BARSLAST(MJ>0 AND REF(MJ,1)<0)>
S5:=IF(MJ>0,S05-REF(S05,BARSLAST(MJ<0)),s05-ref(s05,barslast(mj>0)))/10;
ST:=IF(MJ>0,REF(QST,QXT) QXT,REF(QXT,QST) QST);
RS5:=REF(S5,ST);
BC:IF(MJ>0 AND S5<0 and=”” s5=””>RS5 AND DEA<>
二、MACD多周期(日、周、月)
  MACD多周期指标公式:(通达信)
DIF:EMA(CLOSE,10)-EMA(CLOSE,22);
DEA:EMA(DIF,7);
MACD:(DIF-DEA)*2,COLORSTICK;
DRAWTEXT(CROSS(DIF,DEA),DIF,’☆’),COLORRED;
{DRAWICON(CROSS(DIF,DEA),DIF*1.05,1);
DRAWICON(CROSS(DEA,DIF),DEA*0.90,2);}
月DIF:=’MACD.DIF#MONTH’COLOR0080FF;
月DEA:=’MACD.DEA#MONTH’,COLOR0080FF,LINETHICK2;
周DIF:=’MACD.DIF#WEEK’COLORRED;
周DEA:=’MACD.DEA#WEEK’,COLORRED,LINETHICK2;
日DIF:=’MACD.DIF’,COLORWHITE;
日DEA:=’MACD.DEA’,COLORWHITE,LINETHICK2;
日金:IF(CROSS(日DIF,日DEA),0.1,0),COLORYELLOW;
周金:IF(CROSS(周DIF,周DEA),0.125,0),COLORRED;
月金:IF(CROSS(月DIF,月DEA),0.15,0),COLORGREEN;
DRAWICON(周金 AND 日金,-0.1,7);
DRAWICON(周金 AND 月金,-0.15,11);
DRAWICON(日金 AND 月金,-0.1,1);
日死:IF(CROSS(日DEA,日DIF),-0.1,0),COLORYELLOW;
周死:IF(CROSS(周DEA,周DIF),-0.125,0),COLORRED;
月死:IF(CROSS(月DEA,月DIF),-0.15,0),COLORGREEN;
DRAWICON(周死 AND 日死,-0.1,8);
DRAWICON(周死 AND 月死,-0.15,12);
DRAWICON(日死 AND 月死,-0.15,2);
三、二次金叉,二次翻红,DIF下破0轴及0轴附近金叉
(1)二次金叉:
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:CROSS(DIFF,DEA) AND DEA<0 and=”” count(jccount=””>
(2)二次翻红:
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
FH1:=REF(MACD,1)<>AND REF(MACD,2)<>AND REF(MACD,3)<>
FH2:=MACD>=0 AND COUNT(MACD>REF(MACD,1),1)=1;
FH3:=FH1 AND FH2 AND EMA(C,13)>REF(EMA(C,13),1);
FH4:=FH1 AND FH2 AND ABS((DIFF-DEA)/C)<>
FH5:=FH1 AND FH2 AND MACD<>
FH3 OR FH4 OR FH5;
(3)DIF下破0轴:
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
均线向上:=EMA(C,144)>=REF(EMA(C,144),1) AND EMA(C,233)>=REF(EMA(C,233),1);
破0轴:均线向上 AND REF(DIFF,1)>0 AND DIFF<>
(4)0轴附近金叉(特别是0轴之上):
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9),LINETHICK1;
CROSS(DIF,DEA) AND DEA>-0.05;
四、MACD空中加油
其中参数P1的含义:MACD 0轴之上至当前交易日的天数内曾发生过死叉
P2含义: MACD 0轴之上几日内已发生金叉.
即将发生金叉的条件为:
DIFF在DEA之下, DEA-DIFF小于等于0.05, 且DEA与DIFF差值比前一交易周期小. (这种情况可以关注,有利于激进的朋友提前介入)
N1:=’MACD.DIFF'(12,26,9);
N2:=’MACD.DEA'(12,26,9);
M1:=COUNT(CROSS(N2,N1),P1)>=1;
M2:=(COUNT(CROSS(N1,N2),P2)>=1 OR (N2-N1>=0 AND N2-N1<=0.05 and=””><>
M3:=COUNT(N1>=0,P1)=P1;
M1 AND M2 AND M3;
五、MACD双回试选出4连板牛股
{MACD双回试选股-通达信V2.1 SDCCN}
DIF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIF,9);
MACD:=(DIF-DEA)*2;
A1:=BARSLAST(REF(CROSS(DIF,DEA),1));
DIF多头发散:=DIF/REF(DIF,1)>1.03 AND DIF>0;
N:=4;
DIF1:=EMA(CLOSE,12*N)-EMA(CLOSE,26*N);
DIF1多头发散:=DIF1/REF(DIF1,1)>1.03 AND DIF1>0;
量价关系:=C>REF(C,1) AND VOL/REF(VOL,1)>2;
XUANGU:A1>=5 AND A1<=13 and=”” cross(dif,dea)=”” and=”” dif多头发散=”” and=”” dif1多头发散=”” and=””>
说明:近日符合MACD双回试选股的股票越来越多,V2.1版增加了量价关系限制条件。
六、MACD5分 15分 30分 60分跨周期在同一图表看盘
使用【MACD】5分 15分 30分 60分跨周期在同一图表看盘,做T和做短,使你更清楚自己要做什麽。体验60分与30分如图
{MACD 5分}
分DIFF:=’MACD.DIF#MIN5′(10,22,7.5);
分DEAF:=’MACD.DEA#MIN5′(10,22,7.5);
MACD分:2*(分DIFF-分DEAF),NODRAW;
DRAWBAND(分DIFF,RGB(255,157,255),分DEAF,RGB(21,138,255));
STICKLINE(MACD分>0,0,MACD分,0.01,0) ,COLOR0000FF;
STICKLINE(MACD分<0,0,macd分,0.01,0)>
GMB:IF(CROSS(分DIFF,分DEAF) AND 分DIFF>0,-0.02,DRAWNULL),CROSSDOT,LINETHICK3,COLOR0000FF;
GMC:IF(CROSS(分DIFF,分DEAF) AND 分DIFF<>
0,COLORFFFF00,LINETHICK1;
{MACD 15分}
分DIFF:=’MACD.DIF#MIN15′(10,22,7.5);
分DEAF:=’MACD.DEA#MIN15′(10,22,7.5);
MACD分:2*(分DIFF-分DEAF),NODRAW;
DRAWBAND(分DIFF,RGB(255,157,255),分DEAF,RGB(21,138,255));
STICKLINE(MACD分>0,0,MACD分,0.01,0) ,COLOR0000FF;
STICKLINE(MACD分<0,0,macd分,0.01,0)>
GMB:IF(CROSS(分DIFF,分DEAF) AND 分DIFF>0,-0.02,DRAWNULL),CROSSDOT,LINETHICK3,COLOR0000FF;
GMC:IF(CROSS(分DIFF,分DEAF) AND 分DIFF<>
0,COLORFFFF00,LINETHICK1;
{MACD 30分}
分DIFF:=’MACD.DIF#MIN30′(10,22,7.5);
分DEAF:=’MACD.DEA#MIN30′(10,22,7.5);
MACD分:2*(分DIFF-分DEAF),NODRAW;
DRAWBAND(分DIFF,RGB(255,157,255),分DEAF,RGB(21,138,255));
STICKLINE(MACD分>0,0,MACD分,0.01,0) ,COLOR0000FF;
STICKLINE(MACD分<0,0,macd分,0.01,0)>
GMB:IF(CROSS(分DIFF,分DEAF) AND 分DIFF>0,-0.02,DRAWNULL),CROSSDOT,LINETHICK3,COLOR0000FF;
GMC:IF(CROSS(分DIFF,分DEAF) AND 分DIFF<>
0,COLORFFFF00,LINETHICK1;
{MACD 60分}
分DIFF:=’MACD.DIF#MIN60′(10,22,7.5);
分DEAF:=’MACD.DEA#MIN60′(10,22,7.5);
MACD分:2*(分DIFF-分DEAF),NODRAW;
DRAWBAND(分DIFF,RGB(255,157,255),分DEAF,RGB(21,138,255));
STICKLINE(MACD分>0,0,MACD分,0.01,0) ,COLOR0000FF;
STICKLINE(MACD分<0,0,macd分,0.01,0)>
GMB:IF(CROSS(分DIFF,分DEAF) AND 分DIFF>0,-0.02,DRAWNULL),CROSSDOT,LINETHICK3,COLOR0000FF;
GMC:IF(CROSS(分DIFF,分DEAF) AND 分DIFF<>
0,COLORFFFF00,LINETHICK1;
也可下载下面的文件复制到“tdx_level2T0002pad”的文件夹中,这是做好的,公式是主图
公式源码:
QWX1:=HHV(CLOSE,30);
QWX2:=LLV(CLOSE,30);
QWX3:=CONST((QWX1+QWX2)/2);
DIFF:(EMA(CLOSE,10) – EMA(CLOSE,22))*60+QWX3,NODRAW;
DEA :EMA(DIFF,7.5),NODRAW;
MACD :2*(DIFF-DEA)+QWX3,NODRAW;
DRAWBAND(DIFF,RGB(255,157,255),DEA,RGB(21,138,255));
STICKLINE(MACD>0+QWX3,0+QWX3,MACD,0.2,0) ,COLOR0000FF;
STICKLINE(MACD<0+qwx3,0+qwx3,macd,0.2,0)>
趋势:=((5)*(SMA(((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27)))*(100),5,1))-(3)*(SMA(SMA(((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27)))*(100),5,1),3,1))-SMA(SMA(SMA(((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27)))*(100),5,1),3,1),2,1))*60+QWX3;
STICKLINE(趋势<=5*60+qwx3,0+qwx3,macd,0.2,0)>
0+QWX3,COLORFFFF00,LINETHICK1;
DRAWICON(CROSS(DEA,DIFF) AND DIFF>0+QWX3,DEA,2);
DRAWICON(CROSS(DIFF,DEA) AND DIFF<>

Related Posts