通达信多空MACD+背离公式指标副图贴图
DRAWTEXT(TFILTER(B,MACD>0,1),(DIFF+MACD),'钝化'),COLORRED;
STICKLINE(B OR BG,DIFF,DEA,1,0),COLORRED,LINETHICK1;
DRAWTEXT(TFILTER(底背离消失,B,1),(DIFF*1.05),'消失'),COLORYELLOW;
DRAWTEXT(TFILTER(BG,MACD>0,1),DIFF*1.1,'结构形成'),COLORMAGENTA;
{顶部结构预警}
金叉:=CROSS(DIFF,DEA);
M1:=BARSLAST(金叉),NODRAW;{最近一次金叉的位置}
M2:=REF(BARSLAST(金叉),M1+1),NODRAW;{倒数第二次金叉与倒数第一次金叉的区间}
M3:=REF(BARSLAST(金叉),M2+M1+2),NODRAW;{倒数第三次金叉与倒数第二次金叉的区间}
CH1:=HHV(C,M1+1),NODRAW;{最近一次金叉后,最高收盘价}
DIFH1:=HHV(DIFF,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))-1,INTPART(LOG(-DIFH2))-1);
MDIFH2:=INTPART(DIFH2/POW(10,PDIFH2));
PDIFH3:=IF(DIFH3>0,INTPART(LOG(DIFH3))-1,INTPART(LOG(-DIFH3))-1);
MDIFH3:=INTPART(DIFH3/POW(10,PDIFH3));
MDIFT2:=INTPART(DIFF/POW(10,PDIFH2));
MDIFT3:=INTPART(DIFF/POW(10,PDIFH3));
直接顶背离:=(CH1>CH2 ) AND (MDIFT2<MDIFH2) AND (MACD>0 AND REF(MACD,1)>0) AND MDIFT2>=REF(MDIFT2,1);
隔峰顶背离:=(CH1>CH3 AND CH3>CH2 ) AND (MDIFT3<MDIFH3) AND (MACD>0 AND REF(MACD,1)>0) AND MDIFT3>=REF(MDIFT3,1);
T:直接顶背离 OR 隔峰顶背离,NODRAW;
TG:((MDIFT2<REF(MDIFT2,1))*REF(直接顶背离,1)) OR ((MDIFT3<REF(MDIFT3,1))*REF(隔峰顶背离,1)),NODRAW;
顶背离消失:=(REF(直接顶背离,1) AND DIFH1>=DIFH2 ) OR (REF(隔峰顶背离,1) AND DIFH1>=DIFH3);
DRAWTEXT(TFILTER(T,MACD<0,1),(DIFF+MACD),'钝化'),COLORGREEN;
DRAWTEXT(TFILTER(顶背离消失,T,1),(DIFF*1.05),'消失'),COLORYELLOW;
STICKLINE(T OR TG,DIFF,DEA,1,0),COLORGREEN,LINETHICK1;
DRAWTEXT(TFILTER(TG,MACD<0,1),DIFF*1.02,'结构形成'),COLORMAGENTA;
- 上一篇公式:通达信神奇中线源码主图贴图
- 下一篇公式:止损止盈 实战指标(源码 主图 通达信 贴图)