以下是同花顺macd背离图案副图源码

用法同macd
 MACD指标说明
MACD指数平滑异同移动平均线为两条长、短的平滑平均线。
 其买卖原则为:
1.DIFF、DEA均为正,DIFF向上突破DEA,买入信号参考。
2.DIFF、DEA均为负,DIFF向下跌破DEA,卖出信号参考。
3.DEA线与K线发生背离,行情可能出现反转信号。
4.分析MACD柱状线,由红变绿(正变负),卖出信号参考;由绿变红,买入信号参考。

N:=21;M:=11;
 DIFF1:=EMA(CLOSE,12)-EMA(CLOSE,27);
 DEA1:=EMA(DIFF1,9);
 MACD:=2*(DIFF1-DEA1),STICK;
 DRAWBAND(DIFF1,RGB(200,50,55),DEA1,RGB(0,100,50));
 DIFF:DIFF1,COLOR33FF33;
 DEA:DEA1,coloryellow;
 STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,0.9,0),COLORFF8B00;
 STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,0.3,0),COLORFFAB00;
 STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,0.9,0),COLOR0000DD;
 STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,0.3,0),COLOR0000FF;
 STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,0.9,0),COLORDDDDDD;
 STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,0.3,0),COLORFFFFFF;
 STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,0.9,0),COLORFF8B00;
 STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,0.3,0),COLORFFAB00;
 STICKLINE(MACD>=0 OR MACD<=0,0,0,50,2),colorwhite;
金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
 DRAWICON(金叉,DEA,23);
 DRAWTEXT(金叉,DEA,’ 低金’),coloryellow;
 JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二金:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
 DRAWICON(二金,DEA*1.04,13) ;
 DRAWTEXT(二金,-0.1,’ 二金’),COLORFF00FF;
 A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA);
底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),colorred,POINTDOT;
 DRAWTEXT(底背离,-0.2,’底背’),colormagenta;
 A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF);
顶背:DRAWLINE(A2=0,DEA,顶背离,DEA,0),colorgreen,POINTDOT;
 DRAWTEXT(顶背离,DIFF,’顶背’),colorgreen;
 AA:=REF(HHV(HIGH,N),1);
 BB:=REF(LLV(LOW,N),1);
 GG:=(AA+BB)/2;
 TJ1:=(AA-BB)/GG<(M/100);
 TJ2:=C>REF(HHV(HIGH,N),1);
 XG:=TJ1 AND TJ2;
 LB:=V/REF(V,1)>2;
 W88:金叉 AND XG AND LB;
 STICKLINE(W88,0,0.2,3,0),COLOR00FFFF;

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