请各位老师帮忙优化,特别是红绿柱的长度,如果代码中有无用途之处的,请可删去。谢谢!
N:=7;
N1:=21;
N2:=3;
M:=2.5;
DIFF:EMA(CLOSE,N) - EMA(CLOSE,N1),COLORRED,LINETHICK2;
DEA:EMA(DIFF,N2),COLORGREEN,LINETHICK2;
MACD:(DIFF-DEA)*3,COLORSTICK;
STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,0,0)COLORYELLOW,LINETHICK1;
STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,0,0)COLORWHITE,LINETHICK1;
前期最大值:=REF(HHV(MACD,20),1);
前期最小值:=REF(LLV(MACD,20),1);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
A2:=BARSLAST(REF(CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3)),1));
B2:=REF(C,A2+1)>C AND REF("KDJ.K"(9,3,3),A2+1)<"KDJ.K"(9,3,3) AND CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3));
A3:=BARSLAST(REF(CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24)),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) AND CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
C2:=BARSLAST(REF(CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3)),1));
D2:=REF(C,C2+1)<C AND REF("KDJ.K"(9,3,3),C2+1)>"KDJ.K"(9,3,3) AND CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3));
C3:=BARSLAST(REF(CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24)),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(6,12,24),C3+1)>"RSI.RSI1"(6,12,24) AND CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24));
MACD底背:IF(B1>0,-1,0),COLORRED,POINTDOT;
KDJ底背:IF(B2>0,-1,0),COLORFF00FF,POINTDOT;
RSI底背:IF(B3>0,-1,0),COLORYELLOW,POINTDOT;
MACD顶背:IF(D1>0,1,0),COLOR00FF00,POINTDOT;
KDJ顶背:IF(D2>0,1,0),COLORFFCC66,POINTDOT;
RSI顶背:IF(D3>0,1,0),COLORWHITE,POINTDOT;
STICKLINE(B1>0,前期最小值,0,2,0),COLORRED,LINETHICK2;
STICKLINE(B2>0,前期最小值,0,2,0),COLORFF00FF,LINETHICK2;
STICKLINE(B3>0,前期最小值,0,2,0),COLORYELLOW,LINETHICK2;
STICKLINE(D1>0,0,前期最大值,2,0),COLOR00FF00,LINETHICK2;
STICKLINE(D2>0,0,前期最大值,2,0),COLORFFCC66,LINETHICK2;
STICKLINE(D3>0,0,前期最大值,2,0),COLORWHITE,LINETHICK2;
O轴金叉:=CROSS(DIFF,DEA) AND DIFF<=前期最大值 AND DIFF>=前期最小值;
DRAWICON(O轴金叉,DIFF*1.02,23);
低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
DRAWICON(低位金叉,DEA*1.05,5);
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
DRAWICON(二次金叉,DEA*1.16,11);
K1:=CROSS(MACD,0),COLORLIRED;
IF(RANGE(DIFF,-0.05,0.05) AND K1,前期最大值*3,0),COLORFF00FF;
DRAWTEXT(RANGE(DIFF,-0.05,0.05) AND K1,前期最大值*3.5,'0轴金叉');
AA1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=REF(CLOSE,AA1+1)>CLOSE AND DIFF>REF(DIFF,AA1+1) AND CROSS(DIFF,DEA);
DRAWLINE(AA1=0,DEA,底背离,DEA,0),COLOR5F9F9F,LINETHICK1;
DRAWTEXT(底背离,DEA*1.3,' 底背离'),COLOR5F9F9F;
AA2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=REF(CLOSE,AA2+1)<CLOSE AND REF(DIFF,AA2+1)>DIFF AND CROSS(DEA,DIFF);
DRAWLINE(AA2=0,DEA,顶背离,DEA,0),COLORA68064,LINETHICK1;
DRAWTEXT(顶背离,DEA*1.3,' 顶背离'),COLORA68064;
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;
F:=100;
G:=80;
火焰抄底:IF(REF(COUNT(K<REF(K,1),5)>=5,1) AND COUNT(K<30,5)>=2 AND COUNT(J<0,3)>0 AND CROSS(J,0),前期最小值*1.3,0),COLORRED;
抄底:IF(C<REF(C,1) AND REF(C,1)<REF(C,2) AND REF(C,2)<REF(C,3) AND J>REF(J,1),前期最小值*1.3,0),COLOR888888;
见顶:IF(K>=G AND J<REF(J,1) AND CROSS(F,J),前期最大值*1.3,0),COLORGREEN;
DRAWTEXT(K>=G AND J<REF(J,1) AND CROSS(F,J),前期最大值*1.6,'顶'),COLORGREEN;
买进:=IF(CROSS(J,0) AND C>REF(C,1),8,0),COLORYELLOW ;
低位区翻红买进:=IF(J<5 AND J>REF(J,1) AND C>REF(C,1),16,0),COLORRED;
X:=LLV(J,2)=LLV(J,8);
不涨二次全仓:=IF(CROSS(J,REF(J+0.01,1)) AND X AND J<10 AND C>REF(C,1),24,0),COLORBLUE;
DRAWICON(买进 AND 低位区翻红买进 AND 不涨二次全仓,-ABS(M*MACD)*0.9,17);
BIAS1:=(C-MA(C,6))/MA(C,6)*100;
BIAS2:=(C-MA(C,12))/MA(C,12)*100;
BIAS3:=(C-MA(C,24))/MA(C,24)*100;
BIAS:=(BIAS1+2*BIAS2+3*BIAS3)/6;
乖离:=MA(BIAS,3);
极品底:IF(CROSS(BIAS,乖离) AND 乖离<-9,M*MACD,0),LINETHICK0,COLORRED;
STICKLINE(CROSS(BIAS,乖离) AND 乖离<-9,-ABS(M*MACD),0,1,0),COLORRED;
DRAWTEXT(CROSS(BIAS,乖离) AND 乖离<-9,-ABS(M*MACD),'极品底'),COLORRED;
VAR11:=9999999999999;
VAR21:=LLV(LOW,60);
VAR31:=HHV(HIGH,60);
VAR41:=EMA((CLOSE-VAR21)/(VAR31-VAR21)*100,5);
VAR5:=EMA(0.667*REF(VAR41,1)+0.333*VAR41,2);
VAR6:=OPEN=1.06 AND CLOSE/OPEN>1.12 AND HIGH/ CROSS(VAR41,VAR5) AND VAR41<13;
顶:STICKLINE(CROSS(VAR5,VAR41) AND VAR41>85,0,前期最大值*1.3,1,0),COLOR888888;
DRAWICON(CROSS(VAR5,VAR41) AND VAR41>85,前期最大值*1.6,15);
DRAWTEXT(REF(MACD,1)>0 AND MACD<0,MACD-0.02,'1');
DRAWTEXT(REF(MACD,2)>0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'2');
DRAWTEXT(REF(MACD,3)>0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'3');
DRAWTEXT(REF(MACD,4)>0 AND REF(MACD,3)<0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'4');
DRAWTEXT(REF(MACD,5)>0 AND REF(MACD,4)<0 AND REF(MACD,3)<0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'5');
DRAWTEXT(REF(MACD,6)>0 AND REF(MACD,5)<0 AND REF(MACD,4)<0 AND REF(MACD,3)<0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'6');
DRAWTEXT(REF(MACD,7)>0 AND REF(MACD,6)<0 AND REF(MACD,5)<0 AND REF(MACD,4)<0 AND REF(MACD,3)<0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'7');
DRAWTEXT(REF(MACD,8)>0 AND REF(MACD,7)<0 AND REF(MACD,6)<0 AND REF(MACD,5)<0 AND REF(MACD,4)<0 AND REF(MACD,3)<0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'8');
DRAWTEXT(REF(MACD,9)>0 AND REF(MACD,8)<0 AND REF(MACD,7)<0 AND REF(MACD,6)<0 AND REF(MACD,5)<0 AND REF(MACD,4)<0 AND REF(MACD,3)<0 AND REF(MACD,2)<0 AND REF(MACD,1)<0 AND MACD<0,MACD-0.02,'9');
|