等级: 免费版
- 注册:
- 2022-4-2
- 曾用名:
|

楼主 |
发表于 2023-5-22 14:40
|
显示全部楼层
cc0:tholding;
cc:ref(cc0,1);
那我现在把各个策略都转为序列模式下的后台交易模式,然后在多策略里引用策略里面前一根K线的持仓。策略加载选择当日分笔成交,这样就相当于是下一根K线的开盘成交。就不会有什么问题了吧
ah:stkindiex('','H一箭穿心.cc',0,21,3,10000); //引用3分钟周期上的策略a的仓位。
bh:stkindiex('','H震荡反转.cc',0,3,0,5000); //引用15分钟周期上的策略b的仓位。
zh:'';
total_holding:=ah+bh; //理论持仓
bh_new_month_t:=tbuyholdingex('','',0); //多头今仓
bh_new_month_y:=tbuyholdingex('','',1)-tbuyholdingex('','',0); //多头老仓
sh_new_month_t:=tsellholdingex('','',0); //空头近今仓
sh_new_month_y:=tsellholdingex('','',1)-tsellholdingex('','',0); //空头老仓
new_month_kd_w:=tisremainex(1,'',stklabel); //未成交开多单
new_month_pd_w:=tisremainex(2,'',stklabel); //未成交开多单
new_month_kk_w:=tisremainex(3,'',stklabel); //未成交开空单
new_month_pk_w:=tisremainex(4,'',stklabel); //未成交开多单
new_month_jcc:=(bh_new_month_y+bh_new_month_t)-(sh_new_month_y+sh_new_month_t)+(new_month_kd_w-new_month_kk_w); //实际账户净持仓(不含平仓未成交单)
//理论持仓与实际持仓的判断
if total_holding-new_month_jcc>0 and new_month_jcc>=0 then
tbuy(1,total_holding-new_month_jcc,mkt,0,0,zh);
if total_holding-new_month_jcc>0 and new_month_jcc<0 then begin
tsellshort(total_holding<0,total_holding-new_month_jcc,mkt,0,0,zh);
if total_holding>=0 then begin
tsellshort(1,new_month_jcc,mkt,0,0,zh);
tbuy(total_holding>0,total_holding,mkt,0,0,zh);
end
end
if total_holding-new_month_jcc<0 and new_month_jcc<=0 then
tbuyshort(1,abs(total_holding-new_month_jcc),mkt,0,0,zh);
if total_holding-new_month_jcc<0 and new_month_jcc>0 then begin
tsell(total_holding>0,abs(total_holding-new_month_jcc),mkt,0,0,zh);
if total_holding<=0 then begin
tsell(1,new_month_jcc,mkt,0,0,zh);
tbuyshort(total_holding<0,abs(total_holding),mkt,0,0,zh);
end
end |
|