为什么这里会出现卖出开仓的单子

   if (sl!=0 and SpeLimit!=0 and dir!=0 and lev!=0){

    if (dir==1 and pos.longCurrentVolume==0 and close>SpeLimit and close[1]<=SpeLimit){

    CurPos=pos.longCurrentVolume;

TRes=A_SendOrder(Enum_Buy,Enum_Entry,positions,Q_AskPrice);

Alert("Buy - "+IIFString(TRes, "True", "False")+" - "+Text(CurPos)+" - "+Text(pos.longCurrentVolume));

}

else if (pos.longCurrentVolume>0 and close<SpeLimit and close[1]>=SpeLimit){

CurPos=pos.longCurrentVolume;

TRes=A_SendOrder(Enum_Sell,Enum_Exit,CurPos,Q_BidPrice);

Alert("Sell - "+IIFString(TRes, "True", "False")+" - "+Text(CurPos)+" - "+Text(pos.longCurrentVolume));

}

    else if (dir==-1 and pos.shortCurrentVolume==0 and close<SpeLimit and close[1]>=SpeLimit){

CurPos=pos.shortCurrentVolume;

TRes=A_SendOrder(Enum_Sell,Enum_Entry,positions,Q_BidPrice);

Alert("SellShort - "+IIFString(TRes, "True", "False")+" - "+Text(CurPos)+" - "+Text(pos.shortCurrentVolume));

}

else if(pos.shortCurrentVolume>0 and close>SpeLimit and close[1]<=SpeLimit){

CurPos=pos.shortCurrentVolume;

TRes=A_SendOrder(Enum_Buy,Enum_Exit,Curpos,Q_AskPrice);

Alert("BuyToCover - "+IIFString(TRes, "True", "False")+" - "+Text(CurPos)+" - "+Text(pos.shortCurrentVolume));

}

}

从日志来看,执行了Sell这一组的平多仓的操作,看起来是仓没有平完的时候又执行了Sell部分的代码,但为什么会出现开空仓?结果是多了很多空头头寸。

开仓价卖出
有开仓逻辑限制,为什么还会重复开仓?
只在OnBar里写了个Buy,为什么一个单子都开不出来
量化交易,如何自定义平仓顺序?想浮亏最多的单子优先平仓
onFill里面怎么取到成交单子的方向
为何连续写几个buy,sellshort,会出现单子合并的情况
手动开的单子,怎么程序化平仓
记录开仓价格的函数有异常
请问用什么函数可以获取到单子的来源
为什么用了这个函数加载公式会出现2个同样的周期??

1.代码看上去贴了,但仍然是局部代码

2.日志上可以圈一下 哪个是有问题的单子

3.如果正好出现相反的内容,检查是否开了开平互转