以文本方式查看主题

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

--  作者:aliyun
--  发布时间:2014/8/22 23:00:34
--  无法平空

variable:n:=0; 
variable:nn:=0;
xx:nn,noaxis;

ll:=hhv(h,todaybar); 
if L<=ll-4  and n=0 then begin
buyshort (holding=0,1,limitr,ll-4);
n:=1;
end
 
gg:llv(l,enterbars+1);//,noaxis;

if h>=gg+4  and nn=0 then begin 
sellshort(holding<0,0,limitr,gg+4);
nn:=1;
end

sell(time>150000 and holding>0, 0, market);
sellshort(time>150000 and holding<0, 0, market);
if time=closetime(0) then begin
n:=0;
nn:=0;
end

请问上面代码哪里不对?

红色部份无法平空,去掉nn:=1就可以

加上nn:=1,xx输出时开盘第一K时nn=0,其它都为1

[此贴子已经被作者于2014/8/22 23:01:38编辑过]

--  作者:QQ56048933
--  发布时间:2014/8/23 16:22:09
--  
sellshort(holding<0,0,limitr,gg+4);    这里的平仓手数为什么是0 ,修改该为1看看
--  作者:aliyun
--  发布时间:2014/8/23 22:02:13
--  
不用了,己解决
--  作者:aliyun
--  发布时间:2014/8/24 13:56:26
--  

可否回答一下

加上nn:=1,xx输出时开盘第一K时nn=0,其它都为1


--  作者:pyd
--  发布时间:2014/8/25 8:59:32
--  

因为开盘时nn赋值为0 所以第一根nn输出为0

之后h>=gg+4 and nn=0条件满足nn赋值为1,并且没有再复制为0,一直到第二天开盘又赋值为0.

把holding<0的判断放在then前,这样是平仓后nn赋值为1

if h>=gg+4  and nn=0 and holding<0 then begin 
sellshort(1,0,limitr,gg+4);
nn:=1;
end