分割0.191:(近高-近低)*0.191+近低,DOTLINE,COLORMAGENTA;
分割0.382:(近高-近低)*0.382+近低,DOTLINE,COLORRED;
分割0.5:(近高-近低)*0.5+近低,DOTLINE,COLORGREEN;
分割0.618:(近高-近低)*0.618+近低,DOTLINE,COLORCYAN;
分割0.809:(近高-近低)*0.809+近低,DOTLINE,COLORYELLOW;
TL:=1000000+DA;
TH:=1000000+DB;
TC:=1000000+DC;
TO:=1000000+DO;
AL:=IF(REFDATE(CLOSE,TL)>REFDATE(CLOSE,TH),REFDATE(HIGH,TL),REFDATE(LOW,TL));
BH:=IF(REFDATE(CLOSE,TL)>REFDATE(CLOSE,TH),REFDATE(LOW,TH),REFDATE(HIGH,TH));
CZF:=IF(REFDATE(CLOSE,TL)>REFDATE(CLOSE,TH),REFDATE(HIGH,TC),REFDATE(LOW,TC));
DJB:=IF(REFDATE(CLOSE,TL)>REFDATE(CLOSE,TH),REFDATE(LOW,TO),REFDATE(HIGH,TO));
DRAWLINE(DATE=TO,DJB,DATE=TL,AL,0)CIRCLEDOT,COLORWHITE;
DRAWLINE(DATE=TL,AL,DATE=TH,BH,0)LINETHICK2,COLORYELLOW;
DRAWLINE(DATE=TH,BH,DATE=TC,CZF,0)LINETHICK2,COLORCYAN;
OP:=BH-AL+CZF;
COP:=0.618*(BH-AL)+CZF;
XOP:=IF((1.618*(BH-AL)+CZF)<0,OP,1.618*(BH-AL)+CZF);
TODAY:=DATE;
STICKLINE(DATE=TC,CZF,XOP,0,-1),COLORYELLOW;
DRAWLINE(DATE=TC,COP,DATE=TODAY,COP,1),DOTLINE,COLORYELLOW;
DRAWLINE(DATE=TC,OP,DATE=TODAY,OP,1),DOTLINE,COLORYELLOW;
DRAWLINE(DATE=TC,XOP,DATE=TODAY,XOP,1),DOTLINE,COLORYELLOW;
DRAWTEXT(DATE=TC,COP*1.003,'COP=0.618'),COLORYELLOW;
DRAWTEXT(DATE=TC,OP*1.003,'OP=1.000'),COLORYELLOW;
DRAWTEXT(DATE=TC,XOP*1.003,'XOP=1.618'),COLORYELLOW;
DRAWNUMBER(DATE=TC,COP,COP),COLORMAGENTA;
DRAWNUMBER(DATE=TC,OP,OP),COLORMAGENTA;
DRAWNUMBER(DATE=TC,XOP,XOP),COLORMAGENTA;
F3:=(BH-0.382*(BH-AL));
F5:=(BH-0.5*(BH-AL));
F6:=(BH-0.618*(BH-AL));
{DRAWLINE(DATE=TH,F3,DATE=TODAY,F3,1),LINETHICK4,POINTDOT,COLORYELLOW;
DRAWLINE(DATE=TH,F5,DATE=TODAY,F5,1),LINETHICK4,POINTDOT,COLORYELLOW;
DRAWLINE(DATE=TH,F6,DATE=TODAY,F6,1),LINETHICK4,POINTDOT,COLORYELLOW;}
DRAWTEXT(DATE=TH,F3*1.003,'F3=0.382')COLORYELLOW;
DRAWTEXT(DATE=TH,F5*1.003,'F5=0.500')COLORYELLOW;
DRAWTEXT(DATE=TH,F6*1.003,'F6=0.618')COLORYELLOW;
DRAWNUMBER(DATE=TH,F3,F3)COLORYELLOW;
DRAWNUMBER(DATE=TH,F5,F5)COLORYELLOW;
DRAWNUMBER(DATE=TH,F6,F6)COLORYELLOW;
FF3:=(AL-0.382*(AL-DJB));
FF5:=(AL-0.5*(AL-DJB));
FF6:=(AL-0.618*(AL-DJB));
{DRAWLINE(DATE=TL,FF3,DATE=TODAY,FF3,1),LINETHICK4,POINTDOT,COLORWHITE;
DRAWLINE(DATE=TL,FF5,DATE=TODAY,FF5,1),LINETHICK4,POINTDOT,COLORWHITE;
DRAWLINE(DATE=TL,FF6,DATE=TODAY,FF6,1),LINETHICK4,POINTDOT,COLORWHITE;}
DRAWTEXT(DATE=TL,FF3*1.003,'F3=0.382')COLORWHITE;
DRAWTEXT(DATE=TL,FF5*1.003,'F5=0.500')COLORWHITE;
DRAWTEXT(DATE=TL,FF6*1.003,'F6=0.618')COLORWHITE;
DRAWNUMBER(DATE=TL,FF3,FF3);
DRAWNUMBER(DATE=TL,FF5,FF5);
DRAWNUMBER(DATE=TL,FF6,FF6);
{反向}
TL1:=1000000+DA1;
TH1:=1000000+DB1;
TC1:=1000000+DC1;
TO1:=1000000+DO1;
AL1:=IF(REFDATE(CLOSE,TL1)>REFDATE(CLOSE,TH1),REFDATE(HIGH,TL1),REFDATE(LOW,TL1));
BH1:=IF(REFDATE(CLOSE,TL1)>REFDATE(CLOSE,TH1),REFDATE(LOW,TH1),REFDATE(HIGH,TH1));
CZF1:=IF(REFDATE(CLOSE,TL1)>REFDATE(CLOSE,TH1),REFDATE(HIGH,TC1),REFDATE(LOW,TC1));
DJB1:=IF(REFDATE(CLOSE,TL1)>REFDATE(CLOSE,TH1),REFDATE(LOW,TO1),REFDATE(HIGH,TO1));
OP1:=BH1-AL1+CZF1;
COP1:=0.618*(BH1-AL1)+CZF1;
XOP1:=IF((1.618*(BH1-AL1)+CZF1)<0,OP1,1.618*(BH1-AL1)+CZF1);
STICKLINE(DATE=TC1,CZF1,XOP1,0,-1),COLORGREEN;
DRAWLINE(DATE=TC1,COP1,DATE=TODAY,COP1,1)DOTLINE,COLORGREEN;
DRAWLINE(DATE=TC1,OP1,DATE=TODAY,OP1,1)DOTLINE,COLORGREEN;
DRAWLINE(DATE=TC1,XOP1,DATE=TODAY,XOP1,1)DOTLINE,COLORGREEN;
DRAWTEXT(DATE=TC1,COP1*1.003,'COP=0.618')COLORGREEN;
DRAWTEXT(DATE=TC1,OP1*1.003,'OP=1.000')COLORGREEN;
DRAWTEXT(DATE=TC1,XOP1*1.003,'XOP=1.618')COLORGREEN;
DRAWNUMBER(DATE=TC1,COP1,COP1)COLORMAGENTA;
DRAWNUMBER(DATE=TC1,OP1,OP1)COLORMAGENTA;
DRAWNUMBER(DATE=TC1,XOP1,XOP1)COLORMAGENTA;
DRAWLINE(DATE=TO1,DJB1,DATE=TL1,AL1,0)CIRCLEDOT,COLORYELLOW;
DRAWLINE(DATE=TL1,AL1,DATE=TH1,BH1,0)LINETHICK2,COLORCYAN;
DRAWLINE(DATE=TH1,BH1,DATE=TC1,CZF1,0)LINETHICK2,COLORYELLOW;
F3~:=(BH1-0.382*(BH1-AL1));
F5~:=(BH1-0.5*(BH1-AL1));
F6~:=(BH1-0.618*(BH1-AL1));
F8~:=(BH1-0.809*(BH1-AL1));
{DRAWLINE(DATE=TH1,F3~,DATE=TODAY,F3~,1),LINETHICK4,POINTDOT,COLORCYAN;
DRAWLINE(DATE=TH1,F5~,DATE=TODAY,F5~,1),LINETHICK4,POINTDOT,COLORCYAN;
DRAWLINE(DATE=TH1,F6~,DATE=TODAY,F6~,1),LINETHICK4,POINTDOT,COLORCYAN;
DRAWLINE(DATE=TH1,F8~,DATE=TODAY,F8~,1),LINETHICK4,POINTDOT,COLORCYAN;}
DRAWTEXT(DATE=TH1,F3~*1.003,'F3=0.382')COLORCYAN;
DRAWTEXT(DATE=TH1,F5~*1.003,'F5=0.500')COLORCYAN;
DRAWTEXT(DATE=TH1,F6~*1.003,'F6=0.618')COLORCYAN;
DRAWTEXT(DATE=TH1,F8~*1.003,'F8=0.809')COLORCYAN;
DRAWNUMBER(DATE=TH1,F3~,F3~)COLORCYAN;
DRAWNUMBER(DATE=TH1,F5~,F5~)COLORCYAN;
DRAWNUMBER(DATE=TH1,F6~,F6~)COLORCYAN;
DRAWNUMBER(DATE=TH1,F8~,F8~)COLORCYAN;
FF31:=(AL1-0.382*(AL1-DJB1));
FF51:=(AL1-0.5*(AL1-DJB1));
FF61:=(AL1-0.618*(AL1-DJB1));
{DRAWLINE(DATE=TL1,FF31,DATE=TODAY,FF31,1),LINETHICK4,POINTDOT,COLORWHITE;
DRAWLINE(DATE=TL1,FF51,DATE=TODAY,FF51,1),LINETHICK4,POINTDOT,COLORWHITE;
DRAWLINE(DATE=TL1,FF61,DATE=TODAY,FF61,1),LINETHICK4,POINTDOT,COLORWHITE;}
DRAWTEXT(DATE=TL1,FF31*1.003,'F3=0.382')COLORWHITE;
DRAWTEXT(DATE=TL1,FF51*1.003,'F5=0.500')COLORWHITE;
DRAWTEXT(DATE=TL1,FF61*1.003,'F6=0.618')COLORWHITE;
DRAWNUMBER(DATE=TL1,FF31,FF31);
DRAWNUMBER(DATE=TL1,FF51,FF51);
DRAWNUMBER(DATE=TL1,FF61,FF61);
{顶底背离}
LC:=REF(CLOSE,1);
RSI:=((SMA(MAX((CLOSE - LC),0),3,1) / SMA(ABS((CLOSE - LC)),3,1)) * 100);
FF:=EMA(CLOSE,3);
MA15:=EMA(CLOSE,21);
DRAWTEXT(CROSS(FF,MA15),(LOW * 0.99),'底背离'),COLORRED;
{DRAWICON(CROSS(FF,MA15),(LOW * 0.99),7); }
{顶背离}
RSI1:=((SMA(MAX((CLOSE - (REF(CLOSE,1))),0),3,1) / SMA(ABS((CLOSE - (REF(CLOSE,1)))),3,1))* 100);
DRAWTEXT(CROSS(88,RSI1) AND (MA(C,3))>(EMA(C,3)) ,(HIGH + 0.3),'顶背离'),COLORGREEN;
{DRAWICON(CROSS(88,RSI1) AND (MA(C,3))>(EMA(C,3)) ,(HIGH + 0.3),8); };
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("MACD.DIF","MACD.DEA"),1))+1)>C AND
REF("MACD.DIF",BARSLAST(REF(CROSS("MACD.DIF","MACD.DEA"),1))+1)
<"MACD.DIF" AND CROSS("MACD.DIF","MACD.DEA")
>0,L-0.02,'MACD底背离'),COLORRED;{MACD底背离}
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("KDJ.K","KDJ.D"),1))+1)>C AND
REF("KDJ.K",BARSLAST(REF(CROSS("KDJ.K","KDJ.D"),1))+1)<"KDJ.K" AND
CROSS("KDJ.K","KDJ.D"),L-0.10,'KDJ底背离'),COLORBLUE;{KDJ底背离}
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("RSI.RSI1","RSI.RSI2"),1))+1)>C AND
REF("RSI.RSI1",BARSLAST(REF(CROSS("RSI.RSI1","RSI.RSI2"),1))+1)
<"RSI.RSI1" AND CROSS("RSI.RSI1","RSI.RSI2")
>0,L-0.18,'RSI底背离');{RSI底背离};
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("MACD.DEA","MACD.DIF"),1))+1)
AND REF("MACD.DIF",BARSLAST(REF(CROSS("MACD.DEA","MACD.DIF"),1))+1)
>"MACD.DIF" AND CROSS("MACD.DEA","MACD.DIF")
>0,H+0.16,'MACD顶背离'),COLORGREEN;{MACD顶背离};
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("KDJ.D","KDJ.K"),1))+1)
AND REF("KDJ.K",BARSLAST(REF(CROSS("KDJ.D","KDJ.K"),1))+1)
>"KDJ.K" AND CROSS("KDJ.D","KDJ.K")>0,H+0.08,'KDJ顶背离');{KDJ顶背离};
{涨跌提示}
涨停:=IF((C-REF(C,1))*100/REF(C,1)>=(10-0.01*100/REF(C,1)),1,0);
STICKLINE(涨停,OPEN,CLOSE,1.5,0),COLORYELLOW;
跌停:=IF((REF(C,1)-C)*100/REF(C,1)>=(10-0.01*100/REF(C,1)),1,0);
STICKLINE(跌停,OPEN,CLOSE,1.5,0),COLORWHITE;
机构:=(L2_VOL(0,0) - L2_VOL(0,1))*VOL/CAPITAL;