黄金分割划线买卖
N:=5;//N:=4;
A1:=REF(HIGH,N)=HHV(HIGH,3*N+1);
B1:=FILTER(A1,N);
C1:=BACKSET(B1,N+1);
D1:=FILTER(C1,N);//{高点}
A2:=REF(LOW,N)=LLV(LOW,3*N+1);
B2:=FILTER(A2,N);
C2:=BACKSET(B2,N+1);
D2:=FILTER(C2,N);//{低点}
E1:=(REF(LLV(LOW,2*N),1)+REF(HHV(HIGH,2*N),1))/2;
E2:=(HIGH+LOW)/2;
H1:=(D1 AND NOT((D2 AND E1>=E2))) OR ISLASTBAR OR BARSCOUNT(CLOSE)=1;
L1:=(D2 AND NOT((D1 AND E1<E2))),NODRAW;
H2:=D1 AND NOT((D2 AND E1>=E2));
X1:=REF(BARSLAST(H1),1)+1;
F1:=BACKSET(H1 AND COUNT(L1,X1)>0,LLVBARS(LOW,X1)+1);//LLVBARS(IF(L1,LOW,N000),X1)+1,NODRAW;
G1:=F1>REF(F1,1);//DRAWTEXT(X1,L,'X1');
I1:=BACKSET(G1,1);//DRAWTEXT(F1,H,'F1');
LD:=I1>REF(I1,1);//{过滤后低点}
L2:=LD OR ISLASTBAR OR BARSCOUNT(CLOSE)=1;
X2:=REF(BARSLAST(L2),1)+1;
F2:=BACKSET(L2 AND COUNT(H2,X2)>0,HHVBARS(H,X2)+1);
G2:=F2>REF(F2,1);//DRAWTEXT(HD,H*1.01,'HD');
I2:=BACKSET(G2,1);//DRAWTEXT(LD,L*0.99,'LD');
HD:=I2>REF(I2,1);//{过滤后高点}
DD1:=VALUEWHEN(LD,L);
GD1:=VALUEWHEN(HD,H);
CZ1:= ABS(GD1-REF(DD1,1));//高到低点差价;
CZ2:= ABS(DD1-REF(GD1,1));//低到高点差价;
CJ1:=50<ABS(GD1-REF(DD1,1));//高到低点差超限;
CJ2:=50<ABS(DD1-REF(GD1,1));//低到高低点差超限;
DRAWLINE1(LD,L,HD,H,0),LINETHICK1,COLORYELLOW;//黄色折线
DRAWLINE1(HD,H,LD,L,0),LINETHICK1,COLORBLUE;//蓝色折线
//DRAWNUMBER(CJ2&&LD,L,CZ2,0,COLORYELLOW),ALIGN1,FONTSIZE20,VALIGN0;
//DRAWNUMBER(CJ1&&HD,H,CZ1,0,COLORYELLOW),ALIGN1,FONTSIZE20,VALIGN2;
AA:=EMA(C,5) > EMA(C,20);
BB:=EMA(C,5) < EMA(C,20);
CC:= EMA(C,5) > EMA(C,10);
CC1:=EMA(C,5) < EMA(C,10);
DD:=CLOSE<OPEN;
BBB:=BACKSET(ISLASTBAR,SUMBARS(HD||LD,3));
AAA:=BACKSET(ISLASTBAR,SUMBARS(HD||LD,1));
//DRAWWAVERULER(HD&&BBB,H,LD&&BBB,L,HD&&BBB,H,0,COLORGREEN);//T线条T1///////////////////////////////////上升
//DRAWWAVERULER(HD&&BBB,H,LD&&BBB,L,HD&&BBB,H,0.236,RGB(0,128,255));//T线条T2////上升
//DRAWWAVERULER(HD&&BBB,H,LD&&BBB,L,HD&&BBB,H,0.382,RGB(0,128,255));//T线条T3//上升
//DRAWWAVERULER(HD&&BBB,H,LD&&BBB,L,HD&&BBB,H,0.618,COLORWHITE);//T线条T4//上升
//DRAWWAVERULER(HD&&BBB,H,LD&&BBB,L,HD&&BBB,H,0.764,COLORYELLOW);//T线条T5//上升
//DRAWWAVERULER(HD&&BBB,H,LD&&BBB,L,HD&&BBB,H,1,COLORMAGENTA);//T线条T6//上升
A:=REFX1(BARSLAST(HD)<BARSLAST(LD),0);//10000
转.空.:IF(A&&AAA,VALUEWHEN(HD&&BBB,H)-(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.236,NULL),PRECIS0,RGB(0,128,255);
转空.:IF(A&&AAA,VALUEWHEN(HD&&BBB,H)-(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.382,NULL),PRECIS0,RGB(0,128,255);
中间.:IF(A&&AAA,VALUEWHEN(HD&&BBB,H)-(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.618,NULL),PRECIS0,COLORWHITE;
转多.:IF(A&&AAA,VALUEWHEN(HD&&BBB,H)-(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.764,NULL),PRECIS0,COLORYELLOW;
卖点.:IF(A&&AAA,VALUEWHEN(HD&&BBB,H),NULL),PRECIS0,COLORGREEN;
买点.:IF(A&&AAA,VALUEWHEN(LD&&BBB,L),NULL),PRECIS0,COLORMAGENTA;
买卖差值.:卖点.-买点.,COLORWHITE,NODRAW,PRECIS0;
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)<BARSLAST(LD),卖点.,' 卖0 %'),COLORGREEN,ALIGN0,VALIGN1,FONTSIZE15;//T1//0 %,FONTSIZE16
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)<BARSLAST(LD),转.空.,' 空23.6 %'),RGB(0,128,255),ALIGN0,VALIGN1,FONTSIZE15;//T2//38.2 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)<BARSLAST(LD),转空.,' 空38.2 %'),RGB(0,128,255),ALIGN0,VALIGN1,FONTSIZE15;//T2//38.2 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)<BARSLAST(LD),中间.,' 中61.8 %'),COLORWHITE,ALIGN0,VALIGN1,FONTSIZE15;//T3//50 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)<BARSLAST(LD),转多.,' 多74.6 %'),COLORYELLOW,ALIGN0,VALIGN1,FONTSIZE15;//T4//61.8 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)<BARSLAST(LD),买点.,' 买100 %'),COLORMAGENTA,ALIGN0,VALIGN1,FONTSIZE15;//T5//100 %
转.多:IF(NOT(A)&&AAA,VALUEWHEN(LD&&BBB,L)+(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.236,NULL),PRECIS0,COLORYELLOW;//抬头T2
转多:IF(NOT(A)&&AAA,VALUEWHEN(LD&&BBB,L)+(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.382,NULL),PRECIS0,COLORYELLOW;//抬头T2
中间:IF(NOT(A)&&AAA,VALUEWHEN(LD&&BBB,L)+(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.618,NULL),PRECIS0,COLORWHITE;//抬头T3
转空:IF(NOT(A)&&AAA,VALUEWHEN(LD&&BBB,L)+(VALUEWHEN(HD&&BBB,H)-VALUEWHEN(LD&&BBB,L))*0.764,NULL),PRECIS0,RGB(0,128,255);//抬头T4
卖点:IF(NOT(A)&&AAA,VALUEWHEN(HD&&BBB,H),NULL),PRECIS0,COLORGREEN;//抬头T5
买点:IF(NOT(A)&&AAA,VALUEWHEN(LD&&BBB,L),NULL),PRECIS0,COLORMAGENTA;//抬头T1
买卖差值:卖点-买点,COLORWHITE,NODRAW,PRECIS0;
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)>BARSLAST(LD),买点,' 买0 %'),COLORMAGENTA,ALIGN0,VALIGN1,FONTSIZE15;//T1//0 %,FONTSIZE16
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)>BARSLAST(LD),转.多,' 多23.6 %'),COLORYELLOW,ALIGN0,VALIGN1,FONTSIZE15;//T2//38.2 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)>BARSLAST(LD),转多,' 多38.2 %'),COLORYELLOW,ALIGN0,VALIGN1,FONTSIZE15;//T2//38.2 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)>BARSLAST(LD),中间,' 中61.8 %'),COLORWHITE,ALIGN0,VALIGN1,FONTSIZE15;//T3//50 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)>BARSLAST(LD),转空,' 空76.4 %'),RGB(0,128,255),ALIGN0,VALIGN1,FONTSIZE15;//T4//61.8 %
DRAWTEXT(ISLASTBAR&&BARSLAST(HD)>BARSLAST(LD),卖点,' 卖100 %'),COLORGREEN,ALIGN0,VALIGN1,FONTSIZE15;//T5//100 %
DRAWNUMBER(CROSS(AAA=1,0.5),REFX1(转多,40),REFX1(转多,40),0,COLORYELLOW),ALIGN2,VALIGN1,FONTSIZE15;//卖价格左边
DRAWNUMBER(CROSS(AAA=1,0.5),REFX1(中间,40),REFX1(中间,40),0,COLORWHITE),ALIGN2,VALIGN1,FONTSIZE15;//买价格左边
DRAWNUMBER(CROSS(AAA=1,0.5),REFX1(转空,40),REFX1(转空,40),0,RGB(0,128,255)),ALIGN2,VALIGN1,FONTSIZE15;//卖价格左边
DRAWNUMBER(CROSS(AAA=1,0.5),REFX1(卖点,40),REFX1(卖点,40),0,COLORLIGHTGREEN),ALIGN2,VALIGN1,FONTSIZE15;//买价格左边
DRAWNUMBER(CROSS(AAA=1,0.5),REFX1(买点,40),REFX1(买点,40),0,COLORMAGENTA),ALIGN2,VALIGN1,FONTSIZE15;//卖价格左边