以文本方式查看主题

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

--  作者: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


--  作者: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


--  作者:jinzhe
--  发布时间:2016/5/18 14:25:25
--  

问题在于

 

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

 

类似这样的

position后面都少一个冒号


--  作者:lliang1022
--  发布时间:2016/5/18 14:30:29
--  谢谢,但是更新之后只能开到多头空头开不到又是怎么回事?
如题
--  作者:jinzhe
--  发布时间:2016/5/18 14:35:44
--  

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