以文本方式查看主题

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

--  作者:系统使用者
--  发布时间:2018/2/7 17:31:29
--  开平顺序问题
buy11 :=;
sel11 :=;
buy22 :=;
sel22 :=;
 //交易系统
平空:if holding<0 and trendr=1 then sellshort(1,holding,marketr);
开多1:if holding=0 and buy11 then buy(1,1,marketr);
开多:2:if holding=0 and buy22 then buy(1,1,marketr);

平多:if holding>0 and trendr=-1 then sell(1,holding,marketr);  
开空1:if holding=0 and sel11 then buyshort(1,1,marketr);
开空:2:if holding=0 and sel22 then buyshort(1,1,marketr);
这样开平仓不会混乱吧?

--  作者:FireScript
--  发布时间:2018/2/8 9:50:12
--  
不会,你这个相当于 开仓时候先尝试按照开多1去开,开多1如果不满足条件再开开多2,2个开仓每次最多只能开一个,且开多1优先。下面开空也是类似。逻辑上理清楚了就OK。