下面是BOLL+承压线+买卖背离提示+止损+均线代码,将代码复制到24区(注意22区和23区选中和填写)
五日线:MA(c,5);
十日线:MA(c,10);
二十日线:MA(c,20);
中轨 : MA(CLOSE,N),LINETHICK2;
上轨: MA(CLOSE,N) + P*STD(CLOSE,N),LINETHICK2;
下轨: MA(CLOSE,N) - P*STD(CLOSE,N),LINETHICK2;
承压线:(MA(CLOSE,3)+MA(CLOSE,6)+MA(CLOSE,12)+MA(CLOSE,24))/4,COLORRED,LINETHICK2;
偏离值 : ref(C,1)-承压线;
diff:=ema(c,12)-ema(c,26);
dea:=ema(diff,9);
s1:=sma(c,3,1);
s2:=sma(s1,3,1);
hl:=ma(h,20)-ma(l,20);
if(diff>dea and s2>ref(s2,1),s2-hl,0),colorred,CIRCLEDOT;
if(diff<dea and s2<ref(s2,1),s2+hl,0),colorgreen,CIRCLEDOT;
if(diff>dea and s2<ref(s2,1),s2-hl,0),colorwhite,CIRCLEDOT;
if(diff<dea and s2>ref(s2,1),s2+hl,0),colorwhite,CIRCLEDOT;
{买卖提示}
Var1:=(HIGH+LOW+OPEN+2*CLOSE)/5;
Var2:=REF(Var1,1);
Var3:=SMA((close-Var2),6,1)/SMA(ABS(close-Var2),6,1)*100;
Var4:=(CLOSE-REF(OPEN,29))/REF(OPEN,29)*100;
Var5:=EMA(0.667*REF(Var4,1)+0.333*Var4,5);
Var6:=IF(VOL>=1.3*MA(VOL,5) AND COUNT(Var4>=Var5 and Var4<-17,3) AND REF(LOW,1)=LLV(LOW,120),1,0);
Var7:=SMA(MAX(CLOSE-ref(c,1),0),6,1)/SMA(ABS(CLOSE-ref(c,1)),6,1)*100;
Var8:=SMA(MAX(Var1-Var2,0),10,1)/SMA(ABS(Var1-Var2),10,1)*100;
Var9:=IF(COUNT(Var8<20,5)>=1 AND COUNT(Var1=LLV(Var1,10),10)>=1 AND CLOSE>=OPEN*1.038 AND VOL>MA(VOL,5)*1.2,1,0);
DRAWICON(FILTER(CROSS(ema(c,3),ema(c,5))and ema(ema(c,5),5)>=ref(ema(ema(c,5),5),1)and Var3<50,5),ema(c,3),1);
DRAWICON(FILTER(ref(Var3,1)>81 and Var3<80 OR CROSS(82,Var7),5),high,2);
DRAWTEXT(FILTER(ref(Var3,1)>81 and Var3<80 OR CROSS(82,Var7),5),high,'快卖'),coloryellow;
DRAWTEXT(FILTER(Var9 OR Var6,5),low,'注意买入'),colorred;
轨值差:((上轨-下轨)/中轨)*100,LINETHICK0,COLORE66878;
{背离}
DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,8);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
DRAWTEXT(IF(B1>0,1,0),L-0.1,'MACD底背'),COLORGREEN;
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
A2:=BARSLAST(REF(CROSS(K,D),1));
B2:=REF(C,A2+1)>C AND REF(K,A2+1)<K AND CROSS(K,D);
DRAWTEXT(IF(B2>0,1,0),L-0.25,'KDJ底背'),COLORYELLOW;
LC:=REF(CLOSE,1);
RSI1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;
RSI2:=SMA(MAX(CLOSE-LC,0),12,1)/SMA(ABS(CLOSE-LC),12,1)*100;
A3:=BARSLAST(REF(CROSS(RSI1,RSI2),1));
B3:=REF(C,A3+1)>C AND REF(RSI1,A3+1)<RSI1 AND CROSS(RSI1,RSI2);
DRAWTEXT(IF(B3>0,1,0),L-0.4,'RSI底背'),COLORCYAN;
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
DRAWTEXT(IF(D1>0,1,0),H+0.1,'MACD顶背'),COLORWHITE;
C2:=BARSLAST(REF(CROSS(D,K),1));
D2:=REF(C,C2+1)<C AND REF(K,C2+1)>K AND CROSS(D,K);
DRAWTEXT(IF(D2>0,1,0),H+0.25,'KDJ顶背'),COLORWHITE;
C3:=BARSLAST(REF(CROSS(RSI2,RSI1),1));
D3:=REF(C,C3+1)<C AND REF(RSI1,C3+1)>RSI1 AND CROSS(RSI2,RSI1);
DRAWTEXT(IF(D3>0,1,0),H+0.4,'RSI顶背'),COLORMAGENTA;
4.第三个指标集合线条有点多,所以我只有日线图上用它,日线图以下的删去了均线。操作同上,代码如下
中轨 : MA(CLOSE,N),LINETHICK2;
上轨: MA(CLOSE,N) + P*STD(CLOSE,N),LINETHICK2;
下轨: MA(CLOSE,N) - P*STD(CLOSE,N),LINETHICK2;
承压线:(MA(CLOSE,3)+MA(CLOSE,6)+MA(CLOSE,12)+MA(CLOSE,24))/4,COLORRED,LINETHICK2;
偏离值 : ref(C,1)-承压线;
diff:=ema(c,12)-ema(c,26);
dea:=ema(diff,9);
s1:=sma(c,3,1);
s2:=sma(s1,3,1);
hl:=ma(h,20)-ma(l,20);
if(diff>dea and s2>ref(s2,1),s2-hl,0),colorred,CIRCLEDOT;
if(diff<dea and s2<ref(s2,1),s2+hl,0),colorgreen,CIRCLEDOT;
if(diff>dea and s2<ref(s2,1),s2-hl,0),colorwhite,CIRCLEDOT;
if(diff<dea and s2>ref(s2,1),s2+hl,0),colorwhite,CIRCLEDOT;
{买卖提示}
Var1:=(HIGH+LOW+OPEN+2*CLOSE)/5;
Var2:=REF(Var1,1);
Var3:=SMA((close-Var2),6,1)/SMA(ABS(close-Var2),6,1)*100;
Var4:=(CLOSE-REF(OPEN,29))/REF(OPEN,29)*100;
Var5:=EMA(0.667*REF(Var4,1)+0.333*Var4,5);
Var6:=IF(VOL>=1.3*MA(VOL,5) AND COUNT(Var4>=Var5 and Var4<-17,3) AND REF(LOW,1)=LLV(LOW,120),1,0);
Var7:=SMA(MAX(CLOSE-ref(c,1),0),6,1)/SMA(ABS(CLOSE-ref(c,1)),6,1)*100;
Var8:=SMA(MAX(Var1-Var2,0),10,1)/SMA(ABS(Var1-Var2),10,1)*100;
Var9:=IF(COUNT(Var8<20,5)>=1 AND COUNT(Var1=LLV(Var1,10),10)>=1 AND CLOSE>=OPEN*1.038 AND VOL>MA(VOL,5)*1.2,1,0);
DRAWICON(FILTER(CROSS(ema(c,3),ema(c,5))and ema(ema(c,5),5)>=ref(ema(ema(c,5),5),1)and Var3<50,5),ema(c,3),1);
DRAWICON(FILTER(ref(Var3,1)>81 and Var3<80 OR CROSS(82,Var7),5),high,2);
DRAWTEXT(FILTER(ref(Var3,1)>81 and Var3<80 OR CROSS(82,Var7),5),high,'快卖'),coloryellow;
DRAWTEXT(FILTER(Var9 OR Var6,5),low,'注意买入'),colorred;
轨值差:((上轨-下轨)/中轨)*100,LINETHICK0,COLORE66878;
{背离}
DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);
DEA:=EMA(DIFF,8);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
DRAWTEXT(IF(B1>0,1,0),L-0.1,'MACD底背'),COLORGREEN;
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
A2:=BARSLAST(REF(CROSS(K,D),1));
B2:=REF(C,A2+1)>C AND REF(K,A2+1)<K AND CROSS(K,D);
DRAWTEXT(IF(B2>0,1,0),L-0.25,'KDJ底背'),COLORYELLOW;
LC:=REF(CLOSE,1);
RSI1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;
RSI2:=SMA(MAX(CLOSE-LC,0),12,1)/SMA(ABS(CLOSE-LC),12,1)*100;
A3:=BARSLAST(REF(CROSS(RSI1,RSI2),1));
B3:=REF(C,A3+1)>C AND REF(RSI1,A3+1)<RSI1 AND CROSS(RSI1,RSI2);
DRAWTEXT(IF(B3>0,1,0),L-0.4,'RSI底背'),COLORCYAN;
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
DRAWTEXT(IF(D1>0,1,0),H+0.1,'MACD顶背'),COLORWHITE;
C2:=BARSLAST(REF(CROSS(D,K),1));
D2:=REF(C,C2+1)<C AND REF(K,C2+1)>K AND CROSS(D,K);
DRAWTEXT(IF(D2>0,1,0),H+0.25,'KDJ顶背'),COLORWHITE;
C3:=BARSLAST(REF(CROSS(RSI2,RSI1),1));
D3:=REF(C,C3+1)<C AND REF(RSI1,C3+1)>RSI1 AND CROSS(RSI2,RSI1);
DRAWTEXT(IF(D3>0,1,0),H+0.4,'RSI顶背'),COLORMAGENTA;