{对比背离 }
{参数N 1 99 21}
WR1:=((2)*(C)+H+L)/(4); WR2:=LLV(L,34); WR3:=HHV(H,34);
BW:=(WR1-WR2)/(WR3-WR2); B1:=EMA(BW,8);
线性1:=EMA(B1,5)*100; 线性2:=IF(B1>EMA(B1,5),B1*1.1,B1*0.9)*100;
{长J}RSV1:=(BW-LLV(BW,27))/(HHV(BW,27)-LLV(BW,27))*100;
K1:=SMA(RSV1,5,1); D1:=SMA(K1,5,1); 行:=3*K1-2*D1;
{短J}RSV2:=(BW-LLV(BW,9))/(HHV(BW,9)-LLV(BW,9))*100;
K2:=SMA(RSV2,3,1); D2:=SMA(K2,3,1); 短:=EMA(3*K2-2*D2,5);
短势:=IF(PERIOD>=4,短,行),COLOR8E0000,LINETHICK3;
分:=CONST(LLV(L,90)); 百:=CONST(HHV(H,90))-分;
CC比:=(C-分)/百; HH比:=(H-分)/百;
LL比:=(L-分)/百; OO比:=(O-分)/百;
点:=CONST(LLV(短势,90)); 基:=CONST(HHV(短势,90))-点;
CX:=CC比*基+点; HX:=HH比*基+点; LX:=LL比*基+点; OX:=OO比*基+点;
部低点预选A:=BACKSET(LLV(线性1,5)
部高点预选A:=BACKSET(HHV(线性1,5)>REF(HHV(线性1,4),1),4);
线高天:=BARSLAST(部高点预选A=1)+1;
线高天AA:=HHV(DRAWLINE(线高天=1,线性1,REF(线高天,1)=1,REF(线性1,1),1),2),COLOR00FFFF;
线低天:=BARSLAST(部低点预选A=1)+1;
线低天AA:=HHV(DRAWLINE(线低天=1,线性1,REF(线低天,1)=1,REF(线性1,1),1),2),COLORFF0000;
DRAWBAND(IF(EMA(线高天AA,3)>线性1,EMA(线高天AA,3),线性1),RGB(0,20,35),线性1,RGB(128,0,128));
局部低点预选:=BACKSET(LLV(短势,5)
局部高点预选:=BACKSET(HHV(短势,5)>REF(HHV(短势,4),1),4);
高天:=BARSLAST(局部高点预选=1)+1;
高天AA:=HHV(DRAWLINE(高天=1,短势,REF(高天,1)=1,REF(短势,1),1),2),COLOR00FFFF;
DRAWBAND(MA(高天AA,2),RGB(0,124,224),短势,RGB(255,196,9));
低天:=BARSLAST(局部低点预选=1)+1;
低天AA:=HHV(DRAWLINE(低天=1,短势,REF(低天,1)=1,REF(短势,1),1),2),COLORFF0000;
价低点预选A:=BACKSET(LLV(LX,5)
价高点预选A:=BACKSET(HHV(HX,5)>REF(HHV(HX,4),1),4);
价高:=BARSLAST(价高点预选A=1)+1;
价高AA:=HHV(DRAWLINE(价高=1,HX,REF(价高,1)=1,REF(HX,1),1),2),COLOR0099FF;
价低:=BARSLAST(价低点预选A=1)+1;
价低AA:=HHV(DRAWLINE(价低=1,LX,REF(价低,1)=1,REF(LX,1),1),2),COLORFFF000;
尚势:=IF(短势>低天AA,短势,DRAWNULL)CIRCLEDOT,COLOR0000FF,LINETHICK2;
高离:=IF((短势>=高天AA&&价高AA=REF(价高AA,1)) OR (短势<高天AA&&价高AA>=REF(价高AA,1)),短势,DRAWNULL)CIRCLEDOT,COLOR005500,LINETHICK2;
DRAWBAND(尚势,RGB(255,9,9),尚势*0.9,RGB(255,9,9));
DRAWBAND(高离,RGB(2,96,6),高离*1.1,RGB(2,96,6));
DRAWBAND(IF(EMA(线高天AA,3)>线性1,线性1,EMA(线高天AA,3)),RGB(0,204,35),线性1,RGB(128,0,128));
趋势线:=3*SMA((C-LLV(L,14))/(HHV(H,14)-LLV(L,14))*100,5,1)
-2*SMA(SMA((C-LLV(L,14))/(HHV(H,14)-LLV(L,14))*100,5,1),3,1),COLOR00FFFF,LINETHICK2;
DRAWBAND(趋势线,RGB(254,254,254),趋势线*0.98,RGB(254,254,254));
DRAWICON(CROSS(趋势线,高天AA),高天AA,1);
DRAWICON(CROSS(低天AA,趋势线),低天AA,2);{N 1 99 21}
DRAWTEXT(价高AA=LLV(LLV(价高AA,N),2)&&低天AA>LLV(LLV(低天AA,N),2),LLV(低天AA,5),'背'),COLOR000000;
DRAWTEXT(价低AA=HHV(HHV(价低AA,N),2)&&高天AA
JL:=(HHV(短势,55)-LLV(短势,55))/5;
GT:=短势>REF(短势,1) AND REF(短势,1)
AS1:=BARSLAST(REF(GT,1));
底背离:=REF(L4,AS1+1)>CLOSE AND 短势>REF(短势,AS1+1) AND GT;
底背:DRAWLINE(AS1=0,短势,底背离,REF(短势,AS1),0),COLORFF00FF,LINETHICK3;
STICKLINE(底背离,底背,短势,0.1,0),COLORFF00FF;
DRAWTEXT(底背离,REF(底背,1),' 底背离'),COLORFF00FF;
H4:=HHV(GJ,4);
GT2:=短势REF(短势,2);
AS2:=BARSLAST(REF(GT2,1));
顶背离:= REF(H4,AS2+1)
顶背:DRAWLINE(AS2=0,短势,顶背离,REF(短势,AS2),0),COLORGREEN,LINETHICK2;
STICKLINE(顶背离,短势,顶背,0.1,0),COLORGREEN;
DRAWTEXT(顶背离,REF(顶背,1),' 顶背离'),COLORGREEN;
当下:CONST(短势),COLOR8E0000;