跨周期问题
老师好,我是使用双周期双向持仓交易,小周期会有锁仓的动作,现在需要大周期的每根开盘来检查小周期的持仓是否对等,如果不对等需要对差额进行补齐。现在的问题在于我写的代码,状态变量打不开,不知道问题在哪。以下是部分代码,谢谢老师。 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; } } } }