假定我用KD金死叉来开平仓
如果是上一欠亏损,我就开
应当怎么编
谢谢
NUMPROFIT(1) 具体参考函数说明
IF NUMPROFIT(1)<0 AND 开仓条件 THEN
BUY(,,);
如果连续两次以上亏损怎么写,再开
IF HOLDING=0 and NUMPROFIT(1)<0 THEN BEGIN
BUY (kd ,2,THISCLOSE);
BUYSHORT(KK ,2,THISCLOSE);
END
回测时没有反应
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;
KD:=cross(k,d); //开多条件
PD:=cross(d,k); //平多条件
KK:=pd; //开空条件
PK:=kd; //平空条件
if NUMPROFIT(1)<0 then BEGIN
BUY (kd and holding=0,1,thisclose);
buyshort(KK and holding=0,1,thisclose);
end
if holding>0 THEN begin
sell(PD,1,THISCLOSE);
ENd
if holding<0 then BEGIN
SELLSHORT(PK,1,THISCLOSE)
end
怎么不开仓
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;
variable:n=0;
variable:m=0;
KD:=cross(k,d); //开多条件
PD:=cross(d,k); //平多条件
KK:=pd; //开空条件
PK:=kd; //平空条件
if kd and holding=0 and n=0 then begin
buy(1,1,market);
n:=1;
end
if kk and holding=0 and m=0 then begin
buyshort(1,1,market);
m:=1;
end
if NUMPROFIT(1)<0 and n<>0then BEGIN
buyshort(KK and holding=0,1,thisclose);
end
if NUMPROFIT(1)<0 and m<>0then BEGIN
buy(Kdand holding=0,1,thisclose);
end
if holding>0 THEN begin
sell(PD,1,THISCLOSE);
ENd
if holding<0 then BEGIN
SELLSHORT(PK,1,THISCLOSE)
end
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;
variable:n=0;
variable:m=0;
KD:cross(k,d); //开多条件
PD:cross(d,k); //平多条件
KK:=pd; //开空条件
PK:=kd; //平空条件
if kd and holding=0 and n=0 then begin
buy(1,1,market);
n:=1;
end
if kk and holding=0 and m=0 then begin
buyshort(1,1,market);
m:=1;
end
if NUMPROFIT(1)<0 and n<>0 then BEGIN
buyshort(KK and holding=0,1,thisclose);
end
if NUMPROFIT(1)<0 and m<>0 then BEGIN
buy(Kd and holding=0,1,thisclose);
end
if holding>0 THEN begin
sell(PD,1,THISCLOSE);
ENd
if holding<0 then BEGIN
SELLSHORT(PK,1,THISCLOSE);
end
这个是上个平仓一旦没有亏损,那么后面就不会有后续开仓