RSVK:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSVK,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;
ma3:=ma(c,3);
买入1:=cross(c,ma3) and ma3>=ref(ma3,1)*0.99 ;{日收盘价上穿MA3 }
买入2:=c>ma3 and (c-ma3)/ma3<0.035 and ma3>ref(ma3,1)*0.998 ;{收盘价在MA3上方不远 }
买入3:=c>ma3 and ref(ma3,1)<ref(ma3,2) and ref(ma3,2)<ref(ma3,3);{MA3刚刚向上 }
买入4:= c>ma3 and J<80 and cross(J,D) ;{KDJ的J值在低位,或者J线已经向上行,或者J与D即将或刚刚发生金叉}
不买入1:= J>80 or count( cross(D,J),2)>0;{KDJ的J值处于高位,或者J线高位并向下行,或者J与D即将或已经发生死叉}
不买入2:=(c-ma3)/ma3>=0.035;{ 收盘价高于MA3太远}
不买入3:=o>c*1.02 ;{长阴线不买}
不买入4:="CCI">100;{日CCI向上过100}
不买入5:=ref(c,1)>ref(ma3,1) and ref(c,2)>ref(ma3,2);{股价两天占在MA3之上}
不买入6:=count(ma3>ref(ma3,1)*1.0015,4)>=3;{MA3向上多日}
判断买入:= not(不买入1 or 不买入2 or 不买入3 or 不买入4 or 不买入5 or 不买入6) and (买入1 or 买入2 or 买入3 or 买入4);
买入条件:=filter(判断买入,1);
买入: (count( ref(买入条件,1),3)=0 or cross(J,D)) and count( ref(买入条件,1),1)=0 and 买入条件,colorred;
买入天数:=BARSLAST(买入);
买入价:ref(c,买入天数),linethick0;
手续费:=0.003;
盈亏:100*((c-买入价)/买入价-手续费),linethick0,colore66878;
百分之5止赢:买入价*(1+0.05+手续费),linethick0,color000999;
百分之2止损:买入价*(1-0.025+手续费),coLORgreen,linethick0;
止赢条件:=H>百分之5止赢;
止赢天数:=BARSLAST(止赢条件);
止损条件:=c<百分之2止损;
止损天数:=BARSLAST(止损条件);
止赢:=买入天数> 止赢天数 and 止赢天数<止损天数;
止赢天数2:=BARSLAST(止赢条件 and 止赢 and count(ref(止赢,1),1)=0);
止损:=买入天数>止损天数 and 止赢天数>止损天数;
止损天数2:=BARSLAST(止损 and count(ref(止损,1),1)=0);
drawtext(止赢 and count(ref(止赢,1),1)=0 and 买入天数<止损天数2,0.8,'止赢');
drawicon(止赢 and count(ref(止赢,1),1)=0 and 买入天数<止损天数2,0.5,7);
drawtext(止损 and count(ref(止损,1),1)=0 and 买入天数<止赢天数2,0.4,'止损');
drawicon(止损 and count(ref(止损,1),1)=0 and 买入天数<止赢天数2,0.6,8);