请教:kdj<0时买入100股后价格继续下跌至kdj<-3,此时又买入100股后股价回升,
回升至比kdj<-3时买入的价格涨两个百分点时卖出获利,股价继续回升至比kdj<0时买入的价格涨两个百分点时卖出获利。
input:n(9,1,100,10),p1(3,2,40,4),p2(3,2,40,4);//参数设置
RSV:=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))*100;
K:SMA(RSV,P1,1);
D:SMA(K,P2,1);
J:3*K-2*D,NODRAW;
VARIABLE:pc1:=0,pc2:=0;
if cross(-3,J) and holding>0 then
begin
buy(1,100,marketr);
pc2:=ENTERPRICE;
end
if cross(0,J) and holding=0 then
begin
buy(1,100,marketr);
pc1:=ENTERPRICE;
end
if pc1<>0 and (c-pc1)/pc1>=0.02 and holding>0 then
begin
sell(1,holding,marketr);
pc1:=0;
end
if pc2<>0 and (c-pc2)/pc2>=0.02 and holding>0 then
begin
sell(1,holding,marketr);
pc2:=0;
end
仅供参考。具体使用建议参考后根据自身需求自行进一步修改下。