n:=1;
DL2:=(C*3+O+H+L)/6;
DIFF:=EMA(DL2,12*N)-EMA(DL2,26*N);
DEA:=EMA(DIFF,9*N);
MACD:=2*(DIFF-DEA);
KX:=BARSSINCE(CLOSE);{←首次开盘价距今的天数} {----------------------利用MACD趋势进行精确顶底判断------------------------} 顶部:(MACD顶部+-MACD超跌线)/1.2,DOTLINE; MACD多头:(DIFF修正+-MACD超跌线),COLORWHITE; 空头:(DEA修正+-MACD超跌线),COLORYELLOW; 量能柱:=2*(MACD多头-空头)+中轴,COLOR0000BB,NODRAW; 超前DEA:=(EMA(MACD多头,7)); 超前MACD:=2*(MACD多头-超前DEA)+中轴; MACD多空趋势:DRAWBAND(MACD多头,RGB(225,0,150),空头,RGB(0,50,150)); STICKLINE(量能柱>=REF(量能柱,1)AND 量能柱>中轴,中轴,量能柱,0,0),COLORRED; STICKLINE(量能柱中轴,中轴,量能柱,0,1),COLORRED; STICKLINE(量能柱>REF(量能柱,1)AND 量能柱<中轴,中轴,量能柱,1,0),COLORFFCC66; STICKLINE(量能柱<=REF(量能柱,1)AND 量能柱<中轴,中轴,量能柱,0,1),COLORFFCC66; ZHMACD:=量能柱,COLORWHITE; {---------中轴线重画及顶部线,天际线,海面线,底部线,多空线文字说明-----------} 中轴线:DRAWBAND(中轴,RGB(128,128,255),中轴,RGB(128,128,255)); J中轴:(顶部+底部)/2,DOTLINE; K:=SMA(RSVA,9*N/3,1),COLORFFFFFF,NODRAW; D:=SMA(K,9*N/3,1),COLOR00FFFF,NODRAW; WR:=顶部*(HHV(HIGH,N*9)-CLOSE)/(HHV(HIGH,N*9)-LLV(LOW,N*9)); 上升J:=IF(J>=J中轴,J,DRAWNULL),COLORYELLOW,LINETHICK2; 下降J:=IF(J<=J中轴,J,DRAWNULL),COLORGREEN ,LINETHICK2;
HHN:=CONST(HHV(DIFF,KX));
HLN:=CONST(LLV(DEA,KX));
RC1:=CONST((HHN+HLN)/2);
SS:=((HHN-HLN)/200);
MACD底部:=(-100*SS+RC1)+-(-100*SS+RC1),COLOR669999;
MACD顶部:=(100*SS+RC1)+-(-100*SS+RC1),COLORFF0033;
MACD中轴:=0+-(-100*SS+RC1);
DIFF修正:=DIFF+-(-100*SS+RC1),COLOR008080;
DEA修正:=DEA+-(-100*SS+RC1),COLOR00FF00;
MACD修正:=2*(DIFF修正-DEA修正)+MACD中轴,COLOR0000BB,NODRAW;
MACD超跌:=CONST(LLV(MACD修正,KX));
MACD超跌线:=IF(MACD超跌
天际:=顶部*0.809;
中轴:=MACD中轴+-MACD超跌线;
海面:=顶部*0.191;
底部:=MACD底部;
底部1:底部,DOTLINE;
{-------------------------------传统KDJ指标线重画--------------------------}
RSVA:=(CLOSE-LLV(LOW,9*N))/(HHV(HIGH,9*N)-LLV(LOW,9*N))*顶部;{采用21日月线优化}
KF:=SMA(WR,3*N,1);
DF:=SMA(KF,3*N,1);
JF:3*KF-2*DF,COLORGREEN;
J:3*K-2*D,COLORYELLOW;