跨周期问题

老师好,我是使用双周期双向持仓交易,小周期会有锁仓的动作,现在需要大周期的每根开盘来检查小周期的持仓是否对等,如果不对等需要对差额进行补齐。现在的问题在于我写的代码,状态变量打不开,不知道问题在哪。以下是部分代码,谢谢老师。 OnBarOpen(ArrayRef<Integer> indexs) { Range[1:1] { if((longCurrentContracts <> shortCurrentContracts) and longCurrentContracts > 0 and shortCurrentContracts > 0 ) { position_recover == true; } 以下是onbar //持仓补齐 if(position_recover == true) { if(longCurrentContracts > shortCurrentContracts) { SellShort(data0.longCurrentContracts - data0.shortCurrentContracts,close); position_recover = false; } if(shortCurrentContracts > longCurrentContracts) { buy(shortCurrentContracts - longCurrentContracts,close); position_recover = false; } } } }

看不太明白这个业务逻辑

回复:小周期会按照我的交易规则不断的开多单和空单,当多空都有的时候,大周期的每根开盘需要检查一次小周期多空是否对等,如果不对等,就按照多空之间手数的差额补齐至对等。

回复:比如说小周期5分钟级别,大周期120分钟级别,小周期24根K线内交易产生多头10手,空头7手,大周期下一根K的开盘发现空头少了3手,就在小周期上做空3手补齐至10手对等。

回复:老师还在不