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

楼主 |
发表于 2023-5-22 14:21
|
显示全部楼层
那这种策略组合没问题呀
//策略理论持仓
tren0:stkindiex('','一箭穿心.cc0',0,21,3,10000); //引用3分钟周期上的策略a的h值。
wave0:stkindiex('','震荡反转.cc0',0,3,0,5000); //引用15分钟周期上的策略b的h值。
abcholding:=tren0+wave0;
//上一根k线的理论持仓
tren1:stkindiex('','一箭穿心.cc',0,21,3,10000); //引用3分钟周期上的策略a的h值。
wave1:stkindiex('','震荡反转.cc',0,3,0,5000); //引用15分钟周期上的策略b的h值。
before_abcholding:=tren1+wave1;
//账户多头持仓
tbuyho:tbuyholdingex('',stklabel,1);
//账户空头持仓
tsellho:tsellholdingex('',stklabel,1);
//是否有未成交单,返回1表示有未成交
is_order:tglobalsubmitex(0,'',stklabel,0);
//如果当前品种有挂单或者理论策略的当根k理论持仓没有变化,就不执行
if is_order or (abcholding=before_abcholding) then exit;
else
begin
//多头部分
if abcholding>=0 and tsellho>0 then tsellshort(1,tsellho,lmt,c);//平空
//理论持仓大于0,补仓
if abcholding>0 and abcholding>tbuyho then
begin
tbuy(1,abcholding-tbuyho,lmt,c);
end
//理论持仓大于0,减仓
if abcholding>0 and abcholding<tbuyho then
begin
tsell(1,tbuyho-abcholding,lmt,c);
end
//空头部分
if abcholding<=0 and tbuyho>0 then tsell(1,tbuyho,lmt,c);//平多
//理论持仓小于0,补仓
if abcholding<0 and abs(abcholding)>tsellho then
begin
tbuyshort(1,abs(abcholding)-tsellho,lmt,c);
end
//理论持仓小于0,减仓
if abcholding<0 and abs(abcholding)<tsellho then
begin
tsellshort(1,tsellho-abs(abcholding),lmt,c);
end
end |
|