以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  在一个周期内如果开平仓  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=87536)

--  作者:木瓜
--  发布时间:2015/11/19 23:24:38
--  在一个周期内如果开平仓
在一根K线上,限制开仓就不平仓,平仓就不开仓。应该怎么写?用的是LIMITR
[此贴子已经被作者于2015/11/19 23:26:20编辑过]

--  作者:jinzhe
--  发布时间:2015/11/20 8:57:04
--  

大体上是这样的:开多条件加上exitbars>0,开空条件加上enterbars>0,但是要做特殊处理,避免没有任何的开仓

variable:n=0;

if n=0 and holding=0 and 开多条件 then begin

    buy.........;

    n:=1;

end

 

if n=0 and holding=0 and 开空条件 then begin

    buyshort.........;

    n:=1;

end

 

if n>0 and 开多条件 and exitbars>0 then buy........;

if N>0 and 开空条件 and exitbars>0 then buyshort.......;

 

if 平多条件 and enterbars>0 then sell.....;

if 平空条件 and enterbars>0 then sellshort........;