第一个线满足条件 也执行了代码 但是每次 都返回失败

商品128081,加载策略后,每次 都可以执行buy 语句,但是buy的返回值都是失败,第二个k线成功。 换了很多品种 都是这样? 为什么? Params Numeric up(120); Numeric gridsize(0.5); Vars Series<Numeric> last_price; Series<Numeric> counter(0); Events //此处实现事件函数 //初始化事件函数,策略运行期间,首先运行且只有一次,应用在订阅数据等操作 //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { Commentary(text(last_price)); Commentary(text(counter)); Commentary("last_price[1]=" + text(last_price[1])); Commentary("counter[1]=" + text(counter[1])); Commentary("low=" + text(low)); Commentary("MarketPosition=" + text(MarketPosition)); if (low < up and counter == 0 ) { Commentary("下单"); bool b = buy(100, low); if (b) Commentary("ok"); Else Commentary("no"); PlotAuto("con",b,high); if (b) { last_price = low; counter = counter + 1; } } }

这个我运行稍微看了一下,你的代码就是无论任何条件立马开仓,然后没有平仓,也不在加仓。 照这个逻辑,开仓信号应该出在第一根bar上,后面不会再出现任何信号。不太清楚是哪里觉得不对?