以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  前根K阳线下根开多,前阴线下根开空。  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=61154)

--  作者:qq代人发帖
--  发布时间:2014/1/21 10:25:32
--  前根K阳线下根开多,前阴线下根开空。

请教:前根K阳线下根开多,前阴线下根开空。我就是想测试下发单。
if  ref(c,1)>ref(o,1) then
begin
sellshort(1,1,thisclose);
buy(1,1,MARKET);
end

if ref(c,1)<ref(o,1) then
begin
sell(1,1,thisclose);
buyshort(1,1,market);
end
但实际执行时候,只能一直开多或一直开空,而不是根据前根阳或阴而变化,不明白是咋回事?


--  作者:qq代人发帖
--  发布时间:2014/1/21 10:31:46
--  

您好,开平仓条件加上holding的限制。

if  ref(c,1)>ref(o,1) then
begin
sellshort(holding<0,1,thisclose);
buy(holding=0,1,MARKET);
end

if ref(c,1)<ref(o,1) then
begin
sell(holding>0,1,thisclose);
buyshort(holding=0,1,market);
end