Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:请老师帮忙检查一下模型的问题

1楼
lliang1022 发表于:2016/5/18 14:19:30

回测无法平仓

代码如下,谢谢:

 

input:N(9,1,100,10);
input:P1(3,2,40,4);
input:P2(3,2,40,4);
input:X(10,1,20,1);

Variable:position=0;

//kdj指标
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;

A1:=every(K<60,30);
A2:=every(K>40,30);

A3:=Cross(K,d) and K<20.5 and D<20.5 and Count(K>40,10)=0;
A4:=Cross(D,K) and K>79.5 and D>79.5 and Count(K<60,10)=0;

B1:=C>enterprice+X*MINDIFF or C<enterprice-X*MINDIFF;
B2:=C<enterprice-X*MINDIFF or C>enterprice+X*MINDIFF;

B3:=every(K>60,15);
B4:=every(K<40,15);

IF Holding=0 and position =0 THEN BEGIN
    If A1 then begin
    Buy(1,1,Marketr);
    Position =1;
    end
   
    If A2 then begin
    buyshort(1,1,marketr);
    position = -1;
    end
   
    If A3 then BEGIN
    buy(1,1,marketr);
    position = 2;
    end
   
    If A4 then begin
    Buyshort(1,1,marketr);
    position = -2;
    end
end

If Holding = 1 and position =1 then begin
   If B1 then BEGIN
   sell(1,1,marketr);
   position = 0;
   end
end

If if holding = -1 and position = -1 then begin
   If B2 then BEGIN
   sellshort(1,1,marketr);
   position = 0;
   end
end

If holding = 1 and position = 2 then begin
   If B3 then BEGIN
   sell(1,1,marketr);
   position = 0;
   end
end

If holding = -1 and position = -2 then begin
   If B4 then BEGIN
   sellshort(1,1,marketr);
   position = 0;
   end
end

2楼
jinzhe 发表于:2016/5/18 14:24:52

input:N(9,1,100,10);
input:P1(3,2,40,4);
input:P2(3,2,40,4);
input:X(10,1,20,1);

Variable:position=0;

//kdj指标
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;

A1:=every(K<60,30);
A2:=every(K>40,30);

A3:=Cross(K,d) and K<20.5 and D<20.5 and Count(K>40,10)=0;
A4:=Cross(D,K) and K>79.5 and D>79.5 and Count(K<60,10)=0;

 

B3:=every(K>60,15);
B4:=every(K<40,15);

IF Holding=0 and position =0 THEN BEGIN
    If A1 then begin
    Buy(1,1,Marketr);
    Position: =1;
    end
   
    If A2 then begin
    buyshort(1,1,marketr);
    position: = -1;
    end
   
    If A3 then BEGIN
    buy(1,1,marketr);
    position: = 2;
    end
   
    If A4 then begin
    Buyshort(1,1,marketr);
    position: = -2;
    end
end
B1:=C>enterprice+X*MINDIFF or C<enterprice-X*MINDIFF;
B2:=C<enterprice-X*MINDIFF or C>enterprice+X*MINDIFF;

If Holding = 1 and position =1 then begin
   If B1 then BEGIN
   sell(1,1,marketr);
   position: = 0;
   end
end

If if holding = -1 and position = -1 then begin
   If B2 then BEGIN
   sellshort(1,1,marketr);
   position: = 0;
   end
end

If holding = 1 and position = 2 then begin
   If B3 then BEGIN
   sell(1,1,marketr);
   position: = 0;
   end
end

If holding = -1 and position = -2 then begin
   If B4 then BEGIN
   sellshort(1,1,marketr);
   position: = 0;
   end
end

3楼
jinzhe 发表于:2016/5/18 14:25:25

问题在于

 

sellshort(1,1,marketr);
   position= 0;

 

类似这样的

position后面都少一个冒号

4楼
lliang1022 发表于:2016/5/18 14:30:29
如题
5楼
jinzhe 发表于:2016/5/18 14:35:44

说明你的空头条件难以满足,所以没有空头信号

 

共5 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.03906 s, 3 queries.