所有策略里的开仓必须纳入到这个结构下面。如果是多个开仓条件,也要合并到一起。如果有其他开仓没有使用这部分代码,那么是控制不到的。
[PEL] 复制代码
y:=4;//限制的合约个数
ct:=tholdvarietycount('',0,0);//返回当前合约个数
zh:='';//账户
_str:=zh&'_ct';//超全局变量名称
//判断是否有2个方向的开仓未成交
uncompleted:tisremainex(1,zh,'')+tisremainex(3,zh,'');
if uncompleted=0 then
begin
extgbdataset(_str,ct);
end
开仓条件:1;//开仓条件
buycond:开仓条件 and ct<y and extgbdata(_str)<y;
if buycond then begin
tbuy(1,1,mkt);
extgbdataset(_str,extgbdata(_str)+1);
end
|