多图层开仓问题,开仓价格总是收盘价
我的代码大概是这样的 Range[0:0] { entry_price = Max(Data[index].O,Data[index].UpLine); Commentary("entry_price="+text(entry_price)); Data[index].Buy(1, entry_price); }根据Commentary显示的信息都是正确的,是突破价。但是实际图层成交的是收盘价,不知道哪出的问题。代码也是在OnBar事件中处理的
我的代码大概是这样的 Range[0:0] { entry_price = Max(Data[index].O,Data[index].UpLine); Commentary("entry_price="+text(entry_price)); Data[index].Buy(1, entry_price); }根据Commentary显示的信息都是正确的,是突破价。但是实际图层成交的是收盘价,不知道哪出的问题。代码也是在OnBar事件中处理的
OnBar(ArrayRef<Integer> indexs) { If(time == 0.1445) { Data1.buy(1, (open+close)/2); //买入价格出错,成交价格会在最高点 buy(1, (open+close)/2); //买入价格符合预期 } //只在第2图层执行,则不会出错 range[1:1] { If(time == 0.1445) buy(1, (open+close)/2); } } 我重新做了个简单代码测试,两个品种叠加,使用Data1.buy这种方式,价格会出错。这个处理机制不太明白是怎么回事。
这个是说的实际委托交易的成交价格是收盘价还是什么呢
回复:是的,回测显示的成交价始终是收盘价。我把代码改成放在各自的图层去买卖就能买到突破价,但是集中起来做成截面策略在第0图层买卖就会是这么个情况。