[文华指标]背离第二期 多种不同背离方法的MACD 指标 结构 钝化 文华财经赢顺WH6

宥妆 文化修养 2024-12-15 9 576

[文华指标]背离第二期 多种不同背离方法的MACD 指标 结构 钝化 文华财经赢顺WH6

注意:本指标源码用于文华财经赢顺wh6、睿期wh7软件。
目录
8 MACD新高低背离
9 MACD均线背离
10 MACD结构背离
11 特殊MACD背离
12 MACD连线背离
08
MACD新高低背离
M:=20;
DIFF:EMA(CLOSE,12) - EMA(CLOSE,26);
DEA :EMA(DIFF,9),COLORGREEN;
MACD:2*(DIFF-DEA), COLORSTICK;
AA2000:=CLOSE>REF(HHV(HIGH,M),1) AND  MACD<REF(HHV(MACD,M),1) ;
BB2000:=CLOSE<REF(LLV(LOW,M),1) AND MACD>REF(LLV(MACD,M),1) ;
DRAWTEXT(AA2000,MACD,'▲顶背离'),COLORYELLOW;
DRAWTEXT(BB2000,MACD,'▼低背离'),COLORGREEN;
09
MACD均线背离
DIF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORWHITE;
DEA:EMA(DIF,9),COLORYELLOW;
MACD:(DIF-DEA)*2,COLORSTICK;
A1:=BARSLAST(REF(CROSS(DEA,DIF),1));
A2:=BARSLAST(REF(CROSS(DIF,DEA),1));
DD2022:=HHV(MA(C,2),9)>REF(HHV(MA(C,2),9),A1) AND  HHV(DIF,5)<REF(HHV(DIF,5),A1) AND CROSS(DEA,DIF);
KK2022:=LLV(MA(C,2),9)<REF(LLV(MA(C,2),9),A2) AND  LLV(DIF,5)>REF(LLV(DIF,5),A2) AND CROSS(DIF,DEA);
DRAWTEXT(DD2022,DEA+0.1,'顶背离'),COLORGREEN ;
DRAWTEXT(KK2022,DEA-0.1,'底背离'),COLORYELLOW;
DRAWICON(CROSS(DEA,DIF),DEA,5);
DRAWICON(CROSS(DIF,DEA),DEA,4);
10
MACD结构背离
DIF:100*(EMA(CLOSE,12)-EMA(CLOSE,26));
DEA:EMA(DIF,9);
MACD:(DIF-DEA)*2,COLORSTICK;
KKK2022:=CROSS(DEA,DIF);
N1:=BARSLAST(KKK2022),NODRAW;
N2:=REF(BARSLAST(KKK2022),N1+1),NODRAW;
N3:=REF(BARSLAST(KKK2022),N2+N1+2),NODRAW;
CL1:=LLV(C,N1+1),NODRAW;
DIFL1:=LLV(DIF,N1+1),NODRAW;
CL2:=REF(CL1,N1+1),NODRAW;
DIFL2:=REF(DIFL1,N1+1),NODRAW;
CL3:=REF(CL2,N1+1),NODRAW;
DIFL3:=REF(DIFL2,N1+1),NODRAW;
PDIFL2:=IF(DIFL2>0,INTPART(LOG(DIFL2,10))-1,INTPART(LOG(-(DIFL2),10))-1);
MDIFL2:=INTPART(DIFL2/POW(10,PDIFL2));
PDIFL3:=IF(DIFL3>0,INTPART(LOG(DIFL3,10))-1,INTPART(LOG(-(DIFL3),10))-1);
MDIFL3:=INTPART(DIFL3/POW(10,PDIFL3));
MDIFB2:=INTPART(DIF/POW(10,PDIFL2));
MDIFB3:=INTPART(DIF/POW(10,PDIFL3));
ZJDBL26:=(CL1<CL2 ) AND (MDIFB2>MDIFL2) AND (MACD<0 AND REF(MACD,1)<0) AND MDIFB2<=REF(MDIFB2,1);
GFDBL26:=(CL1<CL3 AND CL3<CL2 ) AND (MDIFB3>MDIFL3) AND (MACD<0 AND REF(MACD,1)<0) AND MDIFB3<=REF(MDIFB3,1);
B:ZJDBL26 OR GFDBL26,NODRAW;
BG:((MDIFB2>REF(MDIFB2,1))*REF(ZJDBL26,1)) OR ((MDIFB3>REF(MDIFB3,1))*REF(GFDBL26,1)),NODRAW;
DBJLX03:=(REF(ZJDBL26,1) AND DIFL1<=DIFL2 ) OR (REF(GFDBL26,1) AND DIFL1<=DIFL3);
TT1:=BARSLAST(MACD>0);
DRAWTEXT(COUNT(B,TT1)=1 AND NOT(REF(COUNT(B,TT1)=1 ,1)),(DIF+MACD),'钝化'),COLORRED;
STICKLINE1(B OR BG,DIF,DEA,1,0),COLORRED;
TT2:=BARSLAST(B);
DRAWTEXT(DBJLX03,(MACD),'消失'),COLORYELLOW;
TT3:=BARSLAST(MACD>0);
DRAWTEXT(COUNT(BG,TT3)=1 AND NOT(REF(COUNT(BG,TT3)=1,1)),DIF*1.1,'结构形成'),COLORMAGENTA;
DDJ2022:=CROSS(DIF,DEA);
M1:=BARSLAST(DDJ2022),NODRAW;
M2:=REF(BARSLAST(DDJ2022),M1+1),NODRAW;
M3:=REF(BARSLAST(DDJ2022),M2+M1+2),NODRAW;
CH1:=HHV(C,M1+1),NODRAW;
DIFH1:=HHV(DIF,M1+1),NODRAW;
CH2:=REF(CH1,M1+1),NODRAW;
DIFH2:=REF(DIFH1,M1+1),NODRAW;
CH3:=REF(CH2,M1+1),NODRAW;
DIFH3:=REF(DIFH2,M1+1),NODRAW;
PDIFH2:=IF(DIFH2>0,INTPART(LOG(DIFH2,10))-1,INTPART(LOG(-(DIFH2),10))-1);
MDIFH2:=INTPART(DIFH2/POW(10,PDIFH2));
PDIFH3:=IF(DIFH3>0,INTPART(LOG(DIFH3,10))-1,INTPART(LOG(-(DIFH3),10))-1);
MDIFH3:=INTPART(DIFH3/POW(10,PDIFH3));
MDIFT2:=INTPART(DIF/POW(10,PDIFH2));
MDIFT3:=INTPART(DIF/POW(10,PDIFH3));
JLDBL26:=(CH1>CH2 ) AND (MDIFT2<MDIFH2) AND (MACD>0 AND REF(MACD,1)>0) AND MDIFT2>=REF(MDIFT2,1);
PHDBL26:=(CH1>CH3 AND CH3>CH2 ) AND (MDIFT3<MDIFH3) AND (MACD>0 AND REF(MACD,1)>0) AND MDIFT3>=REF(MDIFT3,1);
T:JLDBL26 OR PHDBL26,NODRAW;
TG:((MDIFT2<REF(MDIFT2,1))*REF(JLDBL26,1)) OR ((MDIFT3<REF(MDIFT3,1))*REF(PHDBL26,1)),NODRAW;
XSDBL26:=(REF(JLDBL26,1) AND DIFH1>=DIFH2 ) OR (REF(PHDBL26,1) AND DIFH1>=DIFH3);
TT4:=BARSLAST(MACD<0);
DRAWTEXT(COUNT(T,TT4)=1 AND REF(COUNT(T,TT4),1)<1,(DIF+MACD),'钝化'),COLORGREEN;
TT5:=BARSLAST(T);
DRAWTEXT(XSDBL26,(MACD),'消失'),COLORYELLOW;
STICKLINE1(T OR TG,DIF,DEA,1,0),COLORGREEN;
DRAWTEXT(COUNT(TG,TT4)=1 AND REF(COUNT(TG,TT4),1)<1,DIF*1.02,'结构形成'),COLORMAGENTA;
DDBL22:JLDBL26 OR  PHDBL26,NODRAW,COLORGREEN;
DBBL22:ZJDBL26 OR GFDBL26,NODRAW,COLORYELLOW;
DRAWTEXT(DDBL22,0,'顶背'),COLORGREEN;
DRAWTEXT(DBBL22,0,'底背'),COLORGREEN;
11
特殊MACD背离
DIFF4:EMA(CLOSE,12) - EMA(CLOSE,26),COLORBFFF10;
DEA4 :EMA(DIFF4,9);
IF(DIFF4>DEA4 AND DIFF4<0,DIFF4,NULL),COLORBFA4D9,LINETHICK2;
IF(DIFF4>DEA4 AND DIFF4>0,DIFF4,NULL),COLORRED,LINETHICK2;
IF(DEA4<0,DEA4,NULL),COLORBLUE,LINETHICK2;
MACD : 2*(DIFF4-DEA4), COLORSTICK;
MA1:=REF(MACD,1),POINTDOT,COLORGRAY;
STICKLINE1(DEA4>0 AND MACD<MA1 AND MACD>=0,0,MACD,1,1),COLORBFA4D9;
STICKLINE1(DEA4<0 AND MACD>=MA1 AND MACD<0,0,MACD,1,1),COLORBFFF10;
MN:=BARSLAST(CROSS(DEA4,0))+1;
SN:=BARSLAST(CROSS(DIFF4,DEA4))+1;
JISHU:=COUNT(CROSS(DEA4,DIFF4) AND DEA4>0,MN);
DD2000:=CROSS(DEA4,DIFF4) AND JISHU>1 AND HHV(DIFF4,SN)<HHV(DIFF4,MN) AND HHV(H,SN)=HHV(H,MN),NODRAW;
DING:=HHV(DIFF4,MN),POINTDOT,COLORGREEN;
STICKLINE1(DING=REF(DING,1) AND DEA4>0,DING,DING,5,0),COLORGREEN;
DRAWTEXT(DD2000,DING,'DD2000');
DRAWNUMBER1(CROSS(DEA4,DIFF4) AND DEA4>0,DING*1.3,JISHU,0),COLORGREEN;
MN1:=BARSLAST(CROSS(0,DEA4))+1;
JN:=BARSLAST(CROSS(DEA4,DIFF4))+1;
JISHU1:=COUNT(CROSS(DIFF4,DEA4) AND DEA4<0,MN1);
DIBU11:CROSS(DIFF4,DEA4) AND JISHU1>1 AND LLV(DIFF4,MN1)<LLV(DIFF4,JN) AND LLV(L,JN)=LLV(L,MN1),NODRAW;
DI2000:=LLV(DIFF4,MN1),POINTDOT,COLORRED;
STICKLINE1(DI2000=REF(DI2000,1) AND DEA4<0,DI2000,DI2000,5,0),COLORYELLOW;
DRAWTEXT(DIBU11,DI2000,'DIBU11');
DRAWNUMBER1(CROSS(DIFF4,DEA4) AND DEA4<0,DI2000*0.7,JISHU1,0),COLORYELLOW;
12
MACD连线背离
DIFF:EMA(C,12) - EMA(CLOSE,26);
DEA:EMA(DIFF,9);
MACD:2*(DIFF-DEA),NODRAW;
2*(DIFF-DEA),COLORSTICK;
UPCOND:=CROSS(DIFF,DEA);
DOWNCOND:=CROSSDOWN(DIFF,DEA);
END_N1:=SUMBARS(DOWNCOND,1);
RANGE_N1:=REF(SUMBARS(UPCOND,1),END_N1);
END_N2:=SUMBARS(DOWNCOND,2);
HH1:=REF(HV(H,RANGE_N1),END_N1-1);
HH2:=REF(HV(H,RANGE_N1),END_N2-1);
MACD1:=REF(HV(DIFF,RANGE_N1),END_N1-1);
MACD2:=REF(HV(DIFF,RANGE_N1),END_N2-1);
顶背离:=CROSS(0,MACD) && HH1>HH2 && MACD1<MACD2;
DRAWTEXT(顶背离,MACD,'顶背离');
Q:=BACKSET(CROSS(0,MACD),LLVBARS(DIFF,END_N1)+1);
QQ:=BACKSET(顶背离,SUMBARS(Q>REF(Q,1),2));
DRAWLINE1(QQ>REF(QQ,1),DIFF,Q>REF(Q,1),DIFF,0),COLORGREEN,LINETHICK3;
END_M1:=SUMBARS(UPCOND,1);
RANGE_M1:=REF(SUMBARS(DOWNCOND,1),END_M1);
END_M2:=SUMBARS(UPCOND,2);
LL1:=REF(LV(L,RANGE_M1),END_M1-1);
LL2:=REF(LV(L,RANGE_M1),END_M2-1);
MACD3:=REF(LV(DIFF,RANGE_M1),END_M1-1);
MACD4:=REF(LV(DIFF,RANGE_M1),END_M2-1);
底背离:=CROSS(MACD,0) && LL1<LL2 && MACD3>MACD4;
DRAWTEXT(底背离,MACD,'底背离');
W:=BACKSET(CROSS(0,MACD),HHVBARS(DIFF,END_N1)+1);
WW:=BACKSET(底背离,SUMBARS(W>REF(W,1),2));
DRAWLINE1(WW>REF(WW,1),DIFF,W>REF(W,1),DIFF,0),COLORRED,LINETHICK3;
友情提示:本指标公式仅作为知识分享,供交流学习使用,不构成任何投资建议,不作为投资依据。
免责声明:本网站部分内容由用户自行上传,若侵犯了您的权益,请联系我们处理,谢谢!联系QQ:2760375052

分享:

扫一扫在手机阅读、分享本文

宥妆

这家伙太懒。。。

  • 暂无未发布任何投稿。
  • 深度解析,新华保险,稳健经营下的投资机遇与挑战
  • 深度解析,岳阳兴长——稳健投资的绿色能源旗舰
  • 深度解析扬农化工,一份稳健投资的绿色化学指南
  • 探索002486的财富秘密,一部稳健增长的蓝筹力量指南
  • 深入了解161601基金,投资策略与实用攻略
  • 探秘钢铁巨龙的涨跌起伏——深度解析河北钢铁股票行情的魅力与影响
  • 掌握今日美国股市行情,全球经济的晴雨表,您的投资指南
  • 拥抱阳光,把握未来,探索阳光电源股票的绿色动力与投资机遇
  • 探索创新引擎,解开002450这只股市明星的面纱
  • 深度解析,三一重工600031,引领中国工程机械行业的巨头力量
  • 深度解析,600276恒瑞医药,创新药巨头的崛起之路与未来展望
  • 探索黄河旋风,揭秘大自然的神秘力量与民间智慧
  • 深度解析,丹邦科技——电子行业的隐形冠军与投资潜力分析
  • 探索财富绿洲,揭秘股票600567的迷人魅力与投资攻略
  • 凌云股份600480,揭秘制造业的隐形冠军,投资与成长的深度解析
  • 深度解析氯碱化工股票,投资攻略与未来展望
  • 深度解析,600825——探秘股市中的稳健蓝筹力量
  • 深度解析002069,挖掘这只潜力股的投资攻略
  • 探索300148天舟文化的艺术魅力与创新力量
  • 深度解析,600367,一只值得关注的蓝筹股的投资攻略
  • 探秘海鲜界的绿色明珠,獐子岛002069——一场海洋生态的奇妙之旅
  • 揭秘美达蓝筹,探索000782美达股份的时尚制造魅力
  • 深度解析600652股票,投资攻略与策略解析
  • 深度解析,探秘002095股票的投资价值与策略
  • 深度解析,泸州老窖的百年传奇与现代转型之路
  • 女硕士走失13年,收留者家属的深情发声
  • 探索罗牛山的绿色智慧之旅,揭秘深圳股市绿宝石的投资魅力
  • 专家建议,设立医院直播禁区,守护安宁与隐私
  • 探索物产中大600704,一家深耕产业链的领导者
  • 揭秘两枚萝卜章,著名商人诈骗300亿的真相与启示
  • 掌握未来海洋经济的航标,深度解析600150中国船舶的投资机遇与挑战
  • 鸿茅药酒事件,当事人的近况揭示与启示
  • 探索金属界的璀璨星辰,云海金属——从矿石到科技引领者
  • 李子柒又营业了,美食背后的故事与文化传播力量
  • 深度解析,银星能源股票的投资攻略与未来展望
  • 深度解析,纳川股份——一只潜力与挑战并存的股市明星