以下是通达信MACD画线副图指标
通达信MACD画线副图指标
源码
{MACD画线}
{OBV:=DIF;short:12 long:26 mid:9}
DIF:EMA(CLOSE,SHORT)-EMA(CLOSE,LONG);
DEA:EMA(DIF,MID);
MACD:(DIF-DEA)*2,COLORSTICK;
OBV:=DIF;
P:=5;
A1:=REF(OBV,P)=HHV(OBV,2*P+1);{A1赋值:P日前的OBV=2*P+1日内OBV的最高值}
B1:=FILTER(A1,P);{A1的P日过滤}
C1:=BACKSET(B1,P+1);{若B1则将最近P+1周期置为1}
D1:=FILTER(C1,P);{高点,C1的P日过滤}
A2:=REF(OBV,P)=LLV(OBV,2*P+1);
B2:=FILTER(A2,P);
C2:=BACKSET(B2,P+1);
D2:=FILTER(C2,P);{低点}
上:REF(OBV,BARSLAST(D1)),COLORFF00FF,NODRAW;
下:REF(OBV,BARSLAST(D2)),COLOR00FF00,NODRAW;
向上:CROSS(OBV,上*1.01),NODRAW;
相对能量:(OBV-下)/(上-下)*100,COLORYELLOW,NODRAW;
R11:=BACKSET(ISLASTBAR,BARSLAST(D1)+1);
S11:=R11>REF(R11,1);
DRAWLINE(D1,OBV,S11,OBV,1),COLORYELLOW;
{当满足条件D1时,在OBV位置画直线起点,
当满足条件S11时,在OBV位置画直线终点,1表示是否延长.,画黄色}
T11:=BACKSET(ISLASTBAR,BARSLAST(D2)+1);
U11:=T11>REF(T11,1);
DRAWLINE(D2,OBV,U11,OBV,1),COLOR00FF00;
STICKLINE(C>0,下,下,1,0),COLOR00FF00;
STICKLINE(C>0,上,上,1,0),COLORFF00FF;
DRAWTEXT(CROSS(OBV,上*1.01),上,'上'),COLORYELLOW;
DRAWTEXT(CROSS(下*0.99,OBV),下,'下'),COLORYELLOW;
DRAWICON(D1,OBV,1);
DRAWICON(D2,OBV,2);