等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
|
请教:比方说,我持有空仓,现在是开多信号,应该是得到平空和开多的结果,实际是开多没有平空。造成账户是锁仓的情况
轮询的
//如果当前品种理论策略的当根k理论持仓有变化,就不执行
if (ho1=1 AND before_ho1=-1) or (ho1=-1 AND before_ho1=1) then exit;
else
BEGIN
//多头部分
if ho1>=0 and tsellho>0 and tbuyho=0 and BARSTATUS=2 then
BEGIN
A平空LH:sellshort(1,0,market);//平空
END
//理论持仓大于0,补仓
if ho1>0 and ho1>tbuyho and tbuyho=0 and BARSTATUS=2 then
BEGIN
补仓多头: buy(1,ho1-tbuyho,market);
END
//理论持仓大于0,减仓
if ho1>0 and ho1<tbuyho and BARSTATUS=2 then
BEGIN
减仓多头: sell(1,tbuyho-ho1,market);
END
//空头部分
if ho1<=0 and tbuyho>0 and tsellho=0 and BARSTATUS=2 then
BEGIN
B平多LH:sell(1,0,market);//平多
END
//理论持仓小于0,补仓
if ho1<0 and abs(ho1)>tsellho and tsellho=0 and BARSTATUS=2 then
BEGIN
补仓空头: buyshort(1,abs(ho1)-tsellho,market);
END
//理论持仓小于0,减仓
if ho1<0 and abs(ho1)<tsellho and BARSTATUS=2 then
BEGIN
减仓空头: sellshort(1,tsellho-abs(ho1),market);
END
END
|
|