 
等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
|
//策略理论持仓
ho1:stkindiex(stklabel,'BOLL布林带交易系统.ho',0,1,0,500);
//上一根k线的理论持仓
before_ho1:stkindiex(stklabel,'BOLL布林带交易系统.ho',0,1,-1,500);
//账户多头持仓
tbuyho:tbuyholdingex('',STKLABEL,1);
//账户空头持仓
tsellho:tsellholdingex('',STKLABEL,1);
//是否有未成交单,返回1表示有未成交
is_order:TGLOBALSUBMITEX(0,'',stklabel,0);
//如果当前品种有挂单或者理论策略的当根k理论持仓有变化,就不执行
if is_order or (ho1<>before_ho1) then exit;
else
BEGIN
//多头部分
if ho1>=0 and tsellho>0 then tsellshort(1,tsellho,mkt);
//理论持仓大于0,补仓
if ho1>0 and ho1>tbuyho then
BEGIN
tbuy(TOPENPROFITEX('','',1,0)<0,ho1-tbuyho,mkt);
END
//理论持仓大于0,减仓
if ho1>0 and ho1<tbuyho then
BEGIN
tsell(TOPENPROFITEX('','',1,0)<0,tbuyho-ho1,mkt);
END
//空头部分
if ho1<=0 and tbuyho>0 then tsell(1,tbuyho,mkt);
//理论持仓小于0,补仓
if ho1<0 and abs(ho1)>tsellho then
BEGIN
tbuyshort(TOPENPROFITEX('','',2,0)<0,abs(ho1)-tsellho,mkt);
END
//理论持仓小于0,减仓
if ho1<0 and abs(ho1)<tsellho then
BEGIN
tsellshort(TOPENPROFITEX('','',2,0)<0,tsellho-abs(ho1),mkt);
END
END |
|