X1:=18;X2:=18;
a3:=PEAKBARS(4,x1,1); a4:=TROUGHBARS(4,x2,1);
a5:=PEAK(4,x1,1); a6:=TROUGH(4,x2,1);
FH:=A3-INTPART(A3/7)*7-1; FL:=A4-INTPART(A4/7)*7-1; a7:=a5-a6;
DRAWICON(a3=0,A5,9); DRAWICON(a4=0,A6,8);
DRAWNUMBER(a3=0,h*1.02,a4,0),COLORGREEN; DRAWNUMBER(a4=0,l*0.98,a3,0),ColorD9B3FF;
F1:=IF(FH=1,0.191,IF(FH=2,0.382,IF(FH=3,0.5,IF(FH=4,0.618,IF(FH=5,0.809,if(fh=0,1,0))))));
f2:=if(fh=1,1.191,if(fh=2,1.382,if(fh=3,1.5,if(fh=4,1.618,if(fh=5,1.809,if(fh=0,2,2.191))))));
FZ1:=A6+A7*F1; FZ2:=a6+a7*f2;
f3:=hhv(C,4)>fz1*0.94 AND llv(C,4)<FZ1*1.05 and a4<a3;
f4:=hhv(C,4)>fz2*0.94 AND llv(C,4)<FZ2*1.05 and a4<a3;
DRAWSL( f3,FZ1,0,10,0),ColorCDCDCD;
DRAWSL( f4,FZ2,0,10,0),ColorCDCDCD;
DRAWNUMBER(f3<>ref(f3,7) and f3<>ref(f3,14) and f3 ,FZ1,F1*100,1),ColorE2FFD9;
DRAWNUMBER(f4<>ref(f4,7) and f4<>ref(f4,14) and f4 ,FZ2,F2*100,1),ColorE2FFD9;
F5:=IF(Fl=1,0.191,IF(Fl=2,0.382,IF(Fl=3,0.5,IF(Fl=4,0.618,IF(Fl=5,0.809,if(fl=6,0,1))))));
f6:=if(fl=1,1.191,if(fl=2,1.382,if(fl=3,1.5,if(fl=4,1.618,if(fl=5,1.809,if(fl=6,2,2.191))))));
FZ5:=A5-A7*F5; FZ6:=a5-a7*f6;
f7:=hhv(C,4)>fz5*0.94 AND llv(C,4)<FZ5*1.05 and a4>a3;
f8:=hhv(C,4)>fz6*0.94 AND llv(C,4)<FZ6*1.05 and a4>a3;
DRAWSL( f7,FZ5,0,10,0),Color00BBBB;
DRAWSL( f8,FZ6,0,10,0),Color00BBBB;
DRAWNUMBER(f7<>ref(f7,7) and f7<>ref(f7,14) and f7,FZ5,F5*100,1),ColorE2FFD9;
DRAWNUMBER(f8<>ref(f8,7) and f8<>ref(f8,14) and f8,FZ6,F6*100,1),ColorFFF4FF;
a8:=a3=5 or a3=8 or a3=13 or a3=21 or a3=34 or a3=55 or a3=89 or a3=144 or a3=233;
VERTLINE(a8 and (a4>a3 or a4<5)),Color00BBBB,POINTDOT; DRAWNUMBER(a8 and a4>a3,a5,a3,0),ColorCDCDCD;
a9:=a4=5 or a4=8 or a4=13 or a4=21 or a4=34 or a4=55 or a4=89 or a4=144 or a4=233;
VERTLINE(a9 and (a4<a3 or a3<5)),ColorCDCDCD,POINTDOT; DRAWNUMBER(a9 and a4<a3,a6,a4,0),Color00CECE;
DRAWNUMBER(ISLASTBAR,hhv(h,10)*1.02,a4,0),ColorD9B3FF,shift2;
DRAWTEXT(ISLASTBAR,hhv(h,10)*1.02,'天'),ColorD9B3FF,shift6;
DRAWNUMBER(ISLASTBAR,llv(l,10)*0.98,a3,0),COLORGREEN,shift2;
DRAWTEXT(ISLASTBAR,llv(l,10)*0.98,'天'),COLORGREEN,shift6;
gd1:=ref(a5,a4); gr1:=ref(date,a4+ref(a3,a4))+19000001;
dd1:=a6; dr1:=ref(date,a4)+19000001;
gd2:=a5; gr2:=ref(date,a3)+19000001;
dd2:=ref(a6,a3); dr2:=ref(date,a3+ref(a4,a3))+19000001;
高点:if(a4<a3 or a3<5,gd1,gd2),LINETHICK0,COLORYELLOW;
高点日期:if(a4<a3 or a3<5,gr1,gr2),LINETHICK0,COLORYELLOW;
低点:if(a4<a3 or a3<5,dd1,dd2),LINETHICK0,COLORGREEN;
低点日期:if(a4<a3 or a3<5,dr1,dr2),LINETHICK0,COLORGREEN;