HDAY:=15;LDAY:=15;PE:=0;KE:=1;
CURR:=CURRBARSCOUNT;
TCH:=CONST(FINDHIGH(H,0,HDAY*10,1));
GTT:=CONST(BARSLAST(TCH=H))+1;
SX跌H:=CONST(IF(GTT=1,H,REF(H,GTT-1)));
BCL:=CONST(FINDLOW(L,0,LDAY*10,1));
DTT:=CONST(BARSLAST(BCL=L))+1;
SX涨L:=CONST(IF(DTT=1,L,REF(L,DTT-1)));
STICKLINE(1=1,H,L,9,0)COLOR878787;
R:=Abs(GTT-DTT);
DTLT:=IF(DTT>GTT,GTT,DTT);
GTHT:=IF(DTT>GTT,DTT,GTT);
SLXH:=IF(CURR<=GTHT+R/8,(SX跌H+SX涨L)/2,DRAWNULL);
H跌X2:=IF(CURR<=GTHT+R/8,(SX跌H+SLXH)/2,DRAWNULL);
L涨X2:=IF(CURR<=GTHT+R/8,(SLXH+SX涨L)/2,DRAWNULL);
GH跌X:=SX跌H+(SX跌H-SX涨L)/8;
DL涨X:=SX涨L-(SX跌H-SX涨L)/8;
DRAWBAND(IF(CURR<=GTHT+R/8,GH跌X,DRAWNULL),RGB(80,124,124),DL涨X,RGB(80,124,124));
DRAWBAND(IF(CURR<=GTHT+R/8,SX跌H,DRAWNULL),RGB(8,168,168),SX跌H,RGB(8,168,168));
DRAWBAND(IF(CURR<=GTHT+R/8,SX涨L,DRAWNULL),RGB(8,168,168),SX涨L,RGB(8,168,168));
DRAWBAND(IF(CURR<=GTHT+R/8,SX跌H-(SX跌H-SX涨L)/8,DRAWNULL),RGB(80,124,24),SX涨L+(SX跌H-SX涨L)/8,RGB(80,124,24));
DRAWBAND(IF(CURR<=GTHT+R/8,SX跌H-(SX跌H-SX涨L)/4,DRAWNULL),RGB(0,124,154),SX涨L+(SX跌H-SX涨L)/4,RGB(0,124,154));
DRAWBAND(IF(CURR<=GTHT+R/8,SX跌H-(SX跌H-SX涨L)*3/8,DRAWNULL),RGB(80,124,24),SX涨L+(SX跌H-SX涨L)*3/8,RGB(80,124,24));
DRAWBAND(SLXH,RGB(8,168,168),SLXH,RGB(8,168,168));
DRAWTEXT(CURR=GTHT,SX涨L-(SX跌H-SX涨L)/16,''),COLOR8899AA;
PEDAY:=IF(PE=0,0,IF(PE=1,R/2,IF(PE=2,R,IF(PE=3,R*3/2,IF(PE=4,R*2,IF(PE=5,R*5/2,IF(PE=6,R*3,IF(PE=7,R*7/2,
IF(PE=8,R*4,IF(PE=9,R*9/2,IF(PE=10,R*5,R*11/2)))))))))));
DRAWKLINE(IF(KE=2 AND CURR>R/2,REFX(H,R/2),IF(KE=2,DRAWNULL,H)),
IF(KE=2 AND CURR>R/2,REFX(O,R/2),IF(KE=2,DRAWNULL,O)),
IF(KE=2 AND CURR>R/2,REFX(L,R/2),IF(KE=2,DRAWNULL,L)),
IF(KE=2 AND CURR>R/2,REFX(C,R/2),IF(KE=2,DRAWNULL,C)));
X8分:=(SX跌H-SX涨L)/8; X8R:=ROUND(R/8);
八分1:=DRAWLINE(CURR=DTLT+X8R*8,SX涨L,CURR=DTLT,SX跌H,0);
八分2:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H,CURR=DTLT,SX涨L,0);
八分3:=DRAWLINE(CURR=DTLT+X8R*8,SLXH,CURR=DTLT+X8R*4,SX涨L,0);
八分4:=DRAWLINE(CURR=DTLT+X8R*8,SLXH,CURR=DTLT+X8R*4,SX跌H,0);
八分5:=DRAWLINE(CURR=DTLT+X8R*4,SX涨L,CURR=DTLT,SLXH,0);
八分6:=DRAWLINE(CURR=DTLT+X8R*4,SX跌H,CURR=DTLT,SLXH,0);
八分7:=DRAWLINE(CURR=DTLT+X8R*8,X8分+SX涨L,CURR=DTLT+X8R*7,SX涨L,0);
八分8:=DRAWLINE(CURR=DTLT+X8R,SX涨L,CURR=DTLT,X8分+SX涨L,0);
八分9:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H-X8分,CURR=DTLT+X8R*7,SX跌H,0);
八分10:=DRAWLINE(CURR=DTLT+X8R,SX跌H,CURR=DTLT,SX跌H-X8分,0);
八分11:=DRAWLINE(CURR=DTLT+X8R*8,X8分*2+SX涨L,CURR=DTLT+X8R*6,SX涨L,0);
八分12:=DRAWLINE(CURR=DTLT+X8R*2,SX涨L,CURR=DTLT,X8分*2+SX涨L,0);
八分13:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H-X8分*2,CURR=DTLT+X8R*6,SX跌H,0);
八分14:=DRAWLINE(CURR=DTLT+X8R*2,SX跌H,CURR=DTLT,SX跌H-X8分*2,0);
八分15:=DRAWLINE(CURR=DTLT+X8R*8,X8分+SX涨L,CURR=DTLT+X8R,SX跌H,0);
八分16:=DRAWLINE(CURR=DTLT+X8R*8,X8分*2+SX涨L,CURR=DTLT+X8R*2,SX跌H,0);
八分17:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H-X8分,CURR=DTLT+X8R,SX涨L,0);
八分18:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H-X8分*2,CURR=DTLT+X8R*2,SX涨L,0);
八分19:=DRAWLINE(CURR=DTLT+X8R*7,SX跌H,CURR=DTLT,X8分+SX涨L,0);
八分20:=DRAWLINE(CURR=DTLT+X8R*6,SX跌H,CURR=DTLT,X8分*2+SX涨L,0);
八分21:=DRAWLINE(CURR=DTLT+X8R*7,SX涨L,CURR=DTLT,SX跌H-X8分,0);
八分22:=DRAWLINE(CURR=DTLT+X8R*6,SX涨L,CURR=DTLT,SX跌H-X8分*2,0);
八分23:=DRAWLINE(CURR=DTLT+X8R*5,SX跌H,CURR=DTLT,X8分*3+SX涨L,0);
八分24:=DRAWLINE(CURR=DTLT+X8R*3,SX跌H,CURR=DTLT,X8分*5+SX涨L,0);
八分25:=DRAWLINE(CURR=DTLT+X8R*5,SX涨L,CURR=DTLT,SX跌H-X8分*3,0);
八分26:=DRAWLINE(CURR=DTLT+X8R*3,SX涨L,CURR=DTLT,SX跌H-X8分*5,0);
八分27:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H-X8分*5,CURR=DTLT+X8R*5,SX涨L,0);
八分28:=DRAWLINE(CURR=DTLT+X8R*8,SX跌H-X8分*3,CURR=DTLT+X8R*3,SX涨L,0);
八分29:=DRAWLINE(CURR=DTLT+X8R*8,X8分*5+SX涨L,CURR=DTLT+X8R*5,SX跌H,0);
八分30:=DRAWLINE(CURR=DTLT+X8R*8,X8分*3+SX涨L,CURR=DTLT+X8R*3,SX跌H,0);
DRAWBAND(REF(八分1,PEDAY),RGB(255,200,8),REF(八分1,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分2,PEDAY),RGB(255,200,8),REF(八分2,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分3,PEDAY),RGB(255,200,8),REF(八分3,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分4,PEDAY),RGB(255,200,8),REF(八分4,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分5,PEDAY),RGB(255,200,8),REF(八分5,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分6,PEDAY),RGB(255,200,8),REF(八分6,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分7,PEDAY),RGB(255,200,8),REF(八分7,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分8,PEDAY),RGB(255,200,8),REF(八分8,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分9,PEDAY),RGB(255,200,8),REF(八分9,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分10,PEDAY),RGB(255,200,8),REF(八分10,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分11,PEDAY),RGB(255,200,8),REF(八分11,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分12,PEDAY),RGB(255,200,8),REF(八分12,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分13,PEDAY),RGB(255,200,8),REF(八分13,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分14,PEDAY),RGB(255,200,8),REF(八分14,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分15,PEDAY),RGB(255,200,8),REF(八分15,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分16,PEDAY),RGB(255,200,8),REF(八分16,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分17,PEDAY),RGB(255,200,8),REF(八分17,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分18,PEDAY),RGB(255,200,8),REF(八分18,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分19,PEDAY),RGB(255,200,8),REF(八分19,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分20,PEDAY),RGB(255,200,8),REF(八分20,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分21,PEDAY),RGB(255,200,8),REF(八分21,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分22,PEDAY),RGB(255,200,8),REF(八分22,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分23,PEDAY),RGB(255,200,8),REF(八分23,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分24,PEDAY),RGB(255,200,8),REF(八分24,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分25,PEDAY),RGB(255,200,8),REF(八分25,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分26,PEDAY),RGB(255,200,8),REF(八分26,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分27,PEDAY),RGB(255,200,8),REF(八分27,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分28,PEDAY),RGB(255,200,8),REF(八分28,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分29,PEDAY),RGB(255,200,8),REF(八分29,PEDAY),RGB(255,200,8));
DRAWBAND(REF(八分30,PEDAY),RGB(255,200,8),REF(八分30,PEDAY),RGB(255,200,8));
{斐波那契周期}
DRAWTEXT(CURRBARSCOUNT=GTT,SX跌H*1.02,'斐波那契下跌周期'),COLOR00FF00;
DRAWTEXT(CURRBARSCOUNT=GTT,SX跌H*1.01,'1'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-2,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-2,SX跌H*1.01,'3'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-4,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-4,SX跌H*1.01,'5'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-7,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-7,SX跌H*1.01,'8'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-12,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-12,SX跌H*1.01,'13'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-20,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-20,SX跌H*1.01,'21'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-33,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-33,SX跌H*1.01,'34 '),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-54,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-54,SX跌H*1.01,'55'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-67,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-67,SX跌H*1.01,'68'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-88,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-88,SX跌H*1.01,'89'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-109,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-109,SX跌H*1.01,'110'),COLOR00FF00;
STICKLINE(CURRBARSCOUNT=GTT-143,SX跌H,SX涨L,0,0),COLOR556600;
DRAWTEXT(CURRBARSCOUNT=GTT-143,SX跌H*1.01,'144'),COLOR00FF00;
DRAWTEXT(CURRBARSCOUNT=DTT,SX涨L*0.96,'斐波那契上升周期'),COLOR0000FF;
DRAWTEXT(CURRBARSCOUNT=DTT,SX涨L*0.98,'1'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-2,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-2,SX涨L*0.98,'3'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-4,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-4,SX涨L*0.98,'5'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-7,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-7,SX涨L*0.98,'8'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-12,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-12,SX涨L*0.98,'13'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-20,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-20,SX涨L*0.98.01,'21'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-33,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-33,SX涨L*0.98,'34'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-54,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-54,SX涨L*0.98,'55'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-67,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-67,SX涨L*0.98,'68'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-88,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-88,SX涨L*0.98,'89'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-109,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-109,SX涨L*0.98,'110'),COLOR0000FF;
STICKLINE(CURRBARSCOUNT=DTT-143,SX跌H,SX涨L,0,0),COLORAA00AA;
DRAWTEXT(CURRBARSCOUNT=DTT-143,SX涨L*0.98,'144'),COLOR0000FF;