趋势用,周线可做参考,适合慢悠悠的投资者。
// // // // // KDJ
LOWV:=LLV(LOW,PM);
HIGHV:=HHV(HIGH,PM);
RSV:=EMA((CLOSE-LOWV)/(HIGHV-LOWV)*100,3);
K:EMA(RSV,3);
D:MA(K,3);
// 多日滞后K值
AK1:=REF(K,PD);
AK2:=REF(K,(PD+1));
AK3:=REF(K,(PD+2));
AK4:=REF(K,(PD+3));
// 买入条件1:K指标趋势值
BUY1:(AK1-AK2+50+KATC);
// 均线计算,判断上行趋势
AMT:=MA(CLOSE,PT);
// 多日滞后趋势均线
AT1:=REF(AMT,PD);
AT2:=REF(AMT,(PD+1));
// 买入条件2:趋势均线
BUY2:(AT1-AT2)/AT2;
// 均线计算,判断上行趋势
AMH:=MA(CLOSE,PH);
// 多日滞后趋势均线
AH1:=REF(AMH,PD);
AH2:=REF(AMH,(PD+1));
// 买入条件2:趋势均线
BUY3:(AH1-AH2)/AH2;
// 上述三个买入条件的标志
ASP=100;
STICKLINE(BUY1>(50+KATC),ASP,ASP+5,1,0),colorred,Linethick2;
STICKLINE(BUY1<(50+KATC),ASP,ASP+5,1,0),colorgreen,Linethick2;
STICKLINE(BUY2>0,ASP+5,ASP+10,1,0),colorblue,Linethick2;
STICKLINE(BUY3>0,ASP+10,ASP+10+BUY3*1000,1,0),coloryellow,Linethick2;
// 结合在KD图形中的标志
STICKLINE(K>D,50,50+K-D,2,0),colorred;
STICKLINE(D>K,50-(D-K),50,2,0),colorgreen;
// 顶部和底部区域划分线
顶区域:TOP,colorgreen;
中轴线:50,colorred;
底区域:BOTTOM,coloryellow;
// DRAWICON(CROSS(K,D) AND K<=50,12,11),colorred;
// DRAWICON(CROSS(D,K) AND K>=80,88,4),colorgreen;
//A1:=BARSLAST(REF(CROSS(K,D),1));
//底背离:REF(CLOSE,A1+1)>CLOSE AND K>REF(K,A1+1) AND CROSS(K,D);
//DRAWLINE(A1=0,D,底背离,D,0),colorred,LINETHICK1;
//A2:=BARSLAST(REF(CROSS(D,K),1));
//顶背离:REF(CLOSE,A2+1)<CLOSE AND REF(D,A2+1)>D AND CROSS(D,K);
//DRAWLINE(A2=0,D,顶背离,D,0),colorgreen,LINETHICK1;
//DRAWTEXT(底背离>0,D-5,'加仓'),colorred;
//DRAWTEXT(顶背离>0,D-5,'减仓'),colorgreen;
//DRAWTEXT(CROSS(K,D) AND (D < 8),30,'买'),colorred;
//STICKLINE(CROSS(K,D) AND (D < 8)=1,3,20,8,0),colorred;
//DRAWTEXT(CROSS(D,K) AND (D > 85),70,'卖'),colorgreen;
//STICKLINE(CROSS(D,K) AND (D > 85)=1,85,70,8,0),colorgreen
// // // // // MACD
AMK:=1000;
DIFF:=(EMA(CLOSE,9)-EMA(CLOSE,17))*AMK/CLOSE;
DEA:=EMA(DIFF,8),colorred;
MACD:=(DIFF-DEA);
STICKLINE(MACD>=0,MACD,0,4,1),colorred;
STICKLINE(MACD<0,MACD,0,4,1),colorgreen;
STICKLINE(MACD<REF(MACD,1) AND MACD>0,0,MACD,4,0 ),coloryellow;
STICKLINE(MACD>REF(MACD,1) AND MACD<0,0,MACD,4,0 ),colormagenta;
//X1:IF(diff<0,diff,0),COLOR0000FF,LINETHICK2;
//X2:IF(diff<0,0,diff),colormagenta,LINETHICK1;
//X3:IF(diff<dea,diff,dea),COLOR00ff00,linethick1;
//X4:IF(diff>dea,dea,dea),linethick1,COLORffbb11;
//低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
//STICKLINE(低位金叉,DEA*0.86,DEA*0.66,6,0),coloryellow;
//DRAWTEXT(低位金叉,dea*0.86,' 低位金叉'),coloryellow;
//JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
//二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
//STICKLINE(二次金叉,DEA*0.96,DEA*0.76,6,0),ColorFF00FF;
//DRAWICON(二次金叉,dea*1.1,'BUY') ;
//DRAWTEXT(二次金叉,DEA*0.96,' 二次金叉'),ColorFF00FF;
//A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
//底背离:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA);
//STICKLINE(底背离,DEA*1.09,DEA*0.86,6,0),Color00FF00;
//DRAWLINE(A1=0,DEA,底背离,DEA,0),colorred,linethick1;
//DRAWTEXT(底背离,DEA*1.09,' 底背离'),Color6600FF;
//A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
//顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF);
//DRAWLINE(A2=0,DEA,顶背离,DEA,0),colorgreen,linethick1;
//DRAWTEXT(顶背离,DEA*1.2,' 顶背离'),Color00FF00;
// // // // // VR
LC:=REF(CLOSE,1);
AVR:SUM(IF(CLOSE>LC,VOL,0),M1)/SUM(IF(CLOSE<=LC,VOL,0),M1)*20,colorred,Linethick2;