MACD背离指标公式

DIFF:EMA(CLOSE,12)-EMA(CLOSE,27);
DEA:EMA(DIFF,9);
MACD:2*(DIFF-DEA), COLORSTICK,LINETHICK2;
低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
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=2,21)=1;
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;

 

炒权证的主图公式【通达信版】VAR1:=(100 - ((90 * (HHV(HIGH,21) - CLOSE)) / (HHV(HIGH,21) - LLV(LOW,21))));
VAR2:=(100 - ((90 * (HHV(HIGH,21) - CLOSE)) / (HHV(HIGH,21) - LLV(LOW,21))));
VAR3:=(100 - MA(((100 * (HHV(HIGH,6) - CLOSE)) / (HHV(HIGH,6) - LLV(LOW,6))),34));
DRAWICON(CROSS(VAR2,MA(VAR3,6)),(LOW * 0.998),8);
DRAWICON(CROSS(MA(VAR3,6),VAR1),(HIGH * 1.013),9);
DRAWTEXT(CROSS(VAR2,MA(VAR3,6)),(LOW * 0.984),'B '),COLOR4440FF;
DRAWTEXT(CROSS(MA(VAR3,6),VAR1),(HIGH * 1.035),'S '),COLORFFFF34;
年:MA(CLOSE,26),COLOR00FF00,LINETHICK2;
STICKLINE(C>=年 AND C>=O,C,O,7,0),COLORRED;
STICKLINE(C>=年 AND C>=O,H,L,0,0),COLORRED;
STICKLINE(C<年 AND C<=O,C,O,7,1),COLORFFFF00;
STICKLINE(C<年 AND C<=O,H,L,0,1),COLORFFFF00;
STICKLINE(C<年 AND C>O,C,H,0,1),COLORFFFF00;
STICKLINE(C<年 AND C>O,O,L,0,1),COLORFFFF00;
S:=MA(VOL,5)/MA(VOL,60),COLORRED,,LINETHICK2;
A:=MA(S,5),COLORGREEN,,LINETHICK2;
BIAS:=(CLOSE-MA(CLOSE,5))/MA(CLOSE,5)*100; F:=MA(S,121);
RSV:=(CLOSE-LLV(LOW,45))/(HHV(HIGH,45)-LLV(LOW,45))*100;
K:=SMA(RSV,15,1);D:=SMA(K,15,1); J:=3*K-2*D;LC:=REF(CLOSE,1);
RSI:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;
DRAWTEXT(CROSS(84,RSI) , HIGH+0.05,'逃 ▼顶 '),COLORYELLOW ;
DRAWTEXT(CROSS(RSI,11) , LOW-0.05,' 低 ▲吸 '),COLORRED ;
MID := MA(CLOSE,26);
UPPER:= MID + 2*STD(CLOSE,26);
LOWER:= MID - 2*STD(CLOSE,26);
S1:=IF((J<11 AND BIAS>-11 AND CROSS( S,F) AND (S-F)>0.010),2,0),STICK,LINETHICK3,COLORGREEN;
DRAWTEXT(S1=2,LOW-0.05,'关 ▲注 '), COLORBLUE;
DRAWICON( FILTER(CROSS(S,A) AND A<0.5 AND J<20,13),LOW,1 );

 


使用说明:
炒权证时,用5分钟K线图看涨跌的方向,1 分钟K线图决定买卖点。
在上升趋势中买进,趋势不明或横盘只看不买,下降趋势千万不能买进。

 
公式编制思路:利用双重MACD精确确定买入点

 

 

实战macd
 

公式源码:(副图)
DIFF1:=EMA(CLOSE,16) - EMA(CLOSE,58),colorwhite;
DEA1:=EMA(DIFF1,88),coloryellow;
MACD1:2*(DIFF1-DEA1)*100 ;
mamacd1:ma(macd1,5),,colorwhite;
DIFF:=EMA(CLOSE,8) - EMA(CLOSE,26),colorwhite;
DEA:=EMA(DIFF,50),coloryellow;
MACD:2*(DIFF-DEA)*100 ;
mamacd:ma(macd,5),,colorwhite;
STICKLINE(macd1STICKLINE(macd>mamacd,macd1*0.6,0,4,0),COLORyellow;
STICKLINE(macd<0,mamacd,macd1,4,0),COLORgreen;
STICKLINE(macd1>mamacd1 and macd>mamacd ,0,macd1,4,0),COLORred;

DZH2用公式源码:
DIFF1:=EMA(CLOSE,16) - EMA(CLOSE,58);
DEA1:=EMA(DIFF1,88);
MACD1:2*(DIFF1-DEA1)*100,colorff00ff;
mamacd1:ma(macd1,5),colorwhite;
DIFF:=EMA(CLOSE,8) - EMA(CLOSE,26);
DEA:=EMA(DIFF,50);
MACD:2*(DIFF-DEA)*100 ;
mamacd:ma(macd,5),colorwhite;
STICKLINE(macd1STICKLINE(macd>mamacd,macd1*0.6,0,4,0),COLORyellow;
STICKLINE(macd<0,mamacd,macd1,4,0),COLORgreen;
STICKLINE(macd1>mamacd1 and macd>mamacd ,0,macd1,4,0),COLORred;
谢谢sh01

通达信公式源码:
DIFF1:=EMA(CLOSE,16) - EMA(CLOSE,58),COLORWHITE;
DEA1:=EMA(DIFF1,88),COLORYELLOW;
MACD1:2*(DIFF1-DEA1)*100 ;
MAMACD1:MA(MACD1,5),,COLORWHITE;
DIFF:=EMA(CLOSE,8) - EMA(CLOSE,26),COLORWHITE;
DEA:=EMA(DIFF,50),COLORYELLOW;
MACD:2*(DIFF-DEA)*100 ;
MAMACD:MA(MACD,5),,COLORWHITE;
STICKLINE(MACD1STICKLINE(MACD>MAMACD,MACD1*0.6,0,1,0),COLORYELLOW;
STICKLINE(MACD<0,MAMACD,MACD1,1,0),COLORGREEN;
STICKLINE(MACD1>MAMACD1 AND MACD>MAMACD ,0,MACD1,1,0),COLORRED;

不含(未来数据)

使用方法:在零下二次出现红柱线买入。

卖出:红柱线消失卖出。

注意:二次出现红柱时,红柱要比第一次的短,且mamacd1平滑向上。

 

 

MACD短线:适用大智慧.分析家.大智慧L2.同花顺

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);
MACD : 2*(DIFF-DEA), COLORSTICK;
D1:=EMA(C,3)-EMA(C,8);
D2:=EMA(O,3)-EMA(O,8);
D3:=EMA(H,3)-EMA(H,8);
D4:=EMA(L,3)-EMA(L,8);
DRAWICON(cross(d1,diff) and diff<-0.05 ,d4-0.1,1);
DRAWICON(cross(diff,d1) and diff>0.1 ,d3+0.1,2);
STICKLINE(D1>=D2,D1,D2,8,0),COLOR0055AA;
STICKLINE(D1<=D2,D1,D2,8,0),COLOR006600;
STICKLINE(D1>=D2,D1,D2,5,0),COLOR0077CC;
STICKLINE(D1>=D2,D1,D2,3,0),COLOR0099DD;
STICKLINE(D1>=D2,D3,D4,0,0),COLOR00BBFF;
STICKLINE(D1<=D2,D1,D2,5,0),COLOR009900;
STICKLINE(D1<=D2,D1,D2,3,0),COLOR00BB00;
STICKLINE(D1<=D2,D3,D4,0,0),COLOR00EE00;
每次上涨下跌都有信号

LC:=REF(CLOSE,1);
RSI6:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;

选股:RSI6<20;

 

 

黄托底买进-和-黄托底出选股
 

VAR1:=CLOSE>REF(CLOSE,1) AND CLOSE>REF(CLOSE,2);
VAR2:=REF(VAR1,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR3:=REF(VAR2,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR4:=REF(VAR3,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR5:=REF(VAR4,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR6:=REF(VAR5,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR7:=REF(VAR6,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR8:=REF(VAR7,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR9:=REF(VAR8,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VARA:=REF(VAR9,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VARB:=REF(VARA,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VARC:=REF(VARB,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
STICKLINE(VAR1 OR VAR2 OR VAR3 OR VAR4 OR VAR5 OR VAR6 OR VAR7 OR
VAR8 OR VAR9 OR VARA OR VARB OR VARC,CLOSE,REF(CLOSE,1),3,1),COLORRED;{红1}
VARD:=CLOSEVARE:=REF(VARD,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VARF:=REF(VARE,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR10:=REF(VARF,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR11:=REF(VAR10,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR12:=REF(VAR11,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR13:=REF(VAR12,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR14:=REF(VAR13,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR15:=REF(VAR14,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR16:=REF(VAR15,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR17:=REF(VAR16,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR18:=REF(VAR17,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
STICKLINE(VARD OR VARE OR VARF OR VAR10 OR VAR11 OR VAR12 OR VAR13 OR
VAR14 OR VAR15 OR VAR16 OR VAR17 OR VAR18,CLOSE,REF(CLOSE,1),3,0),COLORFFCC66;
VAR19:=REF(VARD OR VARE OR VARF OR VAR10 OR VAR11 OR VAR12 OR VAR13 OR
VAR14 OR VAR15 OR VAR16 OR VAR17 OR VAR18,1) AND VAR1;
STICKLINE(VAR19,REF(CLOSE,1),REF(CLOSE,2),4,1),COLORYELLOW;
VAR1A:=REF(VAR1 OR VAR2 OR VAR3 OR VAR4 OR VAR5 OR VAR6 OR VAR7 OR
VAR8 OR VAR9 OR VARA OR VARB OR VARC,1) AND VARD;
STICKLINE(VAR1A,REF(CLOSE,1),REF(CLOSE,2),5,2),COLOR00FF00{98FD};
STICKLINE(VAR19,REF(CLOSE,1),REF(CLOSE,2),3,0),COLOR00C8FF;
STICKLINE(VAR19,REF(CLOSE,1),REF(CLOSE,2),2,0),COLOR10ECFF;
STICKLINE(VAR19,REF(CLOSE,1),REF(CLOSE,2),2,0),COLOR10FFFF;
STICKLINE(VAR1A,REF(CLOSE,1),REF(CLOSE,2),3,0),COLOR00D900;
STICKLINE(VAR1A,REF(CLOSE,1),REF(CLOSE,2),3,0),COLORBLUE;
STICKLINE(VAR1A,REF(CLOSE,1),REF(CLOSE,2),0,0),COLOR090FF2;
PMA:MA(C,5),COLORWHITE,LINETHICK2;
IF(PMA>REF(PMA,1),PMA,DRAWNULL),COLORRED,LINETHICK2;
IF(PMAX:=(3*C+L+O+H)/6;
多空线:(20*X+19*REF(X,1)+18*REF(X,2)+17*REF(X,3)+16*REF(X,4)+15*REF(X,5)+14*REF(X,6)
+13*REF(X,7)+12*REF(X,8)+11*REF(X,9)+10*REF(X,10)+9*REF(X,11)+8*REF(X,12)
+7*REF(X,13)+6*REF(X,14)+5*REF(X,15)+4*REF(X,16)+3*REF(X,17)+2*REF(X,18)+
REF(X,20))/210,COLORFF00FF,LINETHICK2;
{用法:黄托底买进,蓝压顶卖出。}
DD:=多空线IF(DD,多空线,DRAWNULL),COLOR00FFFF,LINETHICK2;
A:=(PMA>多空线);
IF(A,多空线,DRAWNULL),COLOR33FF33,POINTDOT,LINETHICK4;

------------------------------------
 
选股:
VAR1:=CLOSE>REF(CLOSE,1) AND CLOSE>REF(CLOSE,2);

VARD:=CLOSEVARE:=REF(VARD,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VARF:=REF(VARE,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR10:=REF(VARF,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR11:=REF(VAR10,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR12:=REF(VAR11,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR13:=REF(VAR12,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR14:=REF(VAR13,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR15:=REF(VAR14,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR16:=REF(VAR15,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);
VAR17:=REF(VAR16,1) AND CLOSE<=REF(CLOSE,1) AND CLOSE>=REF(CLOSE,2);
VAR18:=REF(VAR17,1) AND CLOSE>=REF(CLOSE,1) AND CLOSE<=REF(CLOSE,2);

选股:REF(VARD OR VARE OR VARF OR VAR10 OR VAR11 OR VAR12 OR VAR13 OR
VAR14 OR VAR15 OR VAR16 OR VAR17 OR VAR18,1) AND VAR1;

 

 

 

只铁MACD--含买卖点 
 DIFF : EMA(CLOSE,5) - EMA(CLOSE,34), COLORSTICK;
DEA  : EMA(DIFF,5);
MACD := 2*(DIFF-DEA);
攻防要素:DIFF;
防线:DEA;
兵力:MACD ;
出击:IF(CROSS(攻防要素,防线) AND CROSS(兵力,0) AND 攻防要素<=0,-0.2,0),STICK,COLORYELLOW,LINETHICK2;
DRAWICON(CROSS(攻防要素,防线) AND CROSS(兵力,0) AND 攻防要素<=0,攻防要素,1);
快逃:IF(CROSS(防线,攻防要素) AND CROSS(0,兵力) AND 攻防要素>0.2 ,0.2,0),STICK,LINETHICK2,COLOR00FF00;
DRAWICON(CROSS(防线,攻防要素) AND CROSS(0,兵力) AND 攻防要素>0.2,防线,2);
{选股条件:出击=-0.2、快逃=0.2};

MACD主力资金-逃顶

VAR1D:=EMA(CLOSE,2)-EMA(CLOSE,89);
VAR1E:=EMA(VAR1D,30);
VAR1F:=2*(VAR1D-VAR1E)*10;
VAR20:=POW(VAR1F,3)*0.1+POW(VAR1F,2);
VAR25:=IF(VAR1F>0.015,VAR20,0)/45;
拉升资金: VAR25,COLORRED;
VAR26:=EMA(CLOSE,2)-EMA(CLOSE,150);
VAR27:=EMA(VAR26,100);
VAR28:=2*(VAR26-VAR27);
VAR29:=POW(VAR28,3)*0.1+POW(VAR28,1);
主力资金: IF(VAR28>0.1,VAR29,0)*5;

 

{简单买入法}
EMAL3:EMA(MA(L,3),3);
DRAWICON(CROSS(C,EMAL3),L,1);
DRAWICON(CROSS(EMAL3,C),H,2);

 

价量线1

HSV:=IF(SUM(VOL/CAPITAL,20)<1,SUM(VOL/CAPITAL,20),0.998);
VAR1:=DMA(EMA(CLOSE,13),HSV);
QS:=(CLOSE-VAR1)/VAR1*100;
价量线:=SMA(QS,3,1);
LONGCROSS(QS,价量线,10)AND 价量线<-10 OR CROSS(QS,价量线)AND 价量线<-20;

 

价量线2

HSV:=IF(SUM(VOL/CAPITAL,20)<1,SUM(VOL/CAPITAL,20),0.998);
VAR1:=DMA(EMA(CLOSE,13),HSV);
QS:(CLOSE-VAR1)/VAR1*100;
价量线:SMA(QS,3,1);
IF(价量线>REF(价量线,1),价量线,DRAWNULL),COLORRED;0;

转载于:https://www.cnblogs.com/fangquan/p/3965653.html

你可能感兴趣的:(MACD背离指标公式)