以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请问KDJ的一上问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=59001)

--  作者:haizxj
--  发布时间:2013/11/20 13:30:27
--  请问KDJ的一上问题

假定我用KD金死叉来开平仓

如果是上一欠亏损,我就开

应当怎么编

谢谢

[此贴子已经被作者于2013/11/20 13:30:48编辑过]

--  作者:lichenghu
--  发布时间:2013/11/20 13:40:11
--  

NUMPROFIT(1) 具体参考函数说明

 

IF NUMPROFIT(1)<0 AND 开仓条件 THEN

BUY(,,);


--  作者:haizxj
--  发布时间:2013/11/20 14:00:59
--  

如果连续两次以上亏损怎么写,再开

[此贴子已经被作者于2013/11/20 14:01:19编辑过]

--  作者:jinzhe
--  发布时间:2013/11/20 14:08:45
--  
if numprofit(1)<0 and numprofit(2)<0 then buy....;
--  作者:haizxj
--  发布时间:2013/11/20 22:05:59
--  

IF HOLDING=0  and NUMPROFIT(1)<0 THEN BEGIN
BUY (kd ,2,THISCLOSE);
BUYSHORT(KK ,2,THISCLOSE);

END

回测时没有反应

 

 

 


--  作者:jinzhe
--  发布时间:2013/11/21 9:09:02
--  可以用python模块来编写套利回测吗?
代码就这4句?
--  作者:haizxj
--  发布时间:2013/11/25 9:57:31
--  

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

 

 

怎么不开仓


--  作者:jinzhe
--  发布时间:2013/11/25 10:00:09
--  

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


--  作者:haizxj
--  发布时间:2013/11/25 10:17:18
--  
回测股指12没反应,没成交明细
--  作者:jinzhe
--  发布时间:2013/11/25 10:26:30
--  

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

 

 

这个是上个平仓一旦没有亏损,那么后面就不会有后续开仓