策略实盘模拟中,平仓时自动下单错误,应该平仓结果又做多
我设置的平仓时间是14:50,在14:50买入应该是平仓,结果还是开仓Params Numeric coe(0.7); Vars Numeric hp; Numeric lp; Numeric Myprice; Events OnBar(ArrayRef<Integer> indexs) { hp=Highest(High[1],2)*(1+coe/1000); lp=Lowest(Low[1],2)*(1-coe/1000); //入场 // 价格上升做多 If(MarketPosition==0 && High>=hp && time>=0.0945) { MyPrice=Max(open,hp); MyPrice = IIF(BarStatus==2,0,MyPrice); Buy(1,MyPrice); //多头建仓 Commentary(price:+text(MyPrice)); } // 价格下降做空 If(MarketPosition==0 &&low<=lp && time>=0.0945) { MyPrice=Min(Open,lp); MyPrice = IIF(BarStatus==2,0,MyPrice); SellShort(1,MyPrice); //空头建仓 } //出场 // 已做多,看跌 If(MarketPosition>0 && low<=lp ) { MyPrice=Min(Open,lp); MyPrice = IIF(BarStatus==2,0,MyPrice); Sell(0,MyPrice); //多头平仓 } // 已做空,价格看涨 If(MarketPosition<0 && High>=hp) { MyPrice=Max(open,hp); MyPrice = IIF(BarStatus==2,0,MyPrice); BuyToCover(0,MyPrice); //空头平仓 } // 已做多,日内平仓 if(MarketPosition==1 && time>=0.1450) { MyPrice=open; MyPrice = IIF(BarStatus==2,0,MyPrice); Sell(0,MyPrice); //多头平仓 } // 已做空,日内平仓 if(MarketPosition==-1 && time>=0.1450) { MyPrice=open; MyPrice = IIF(BarStatus==2,0,MyPrice); BuyToCover(0,MyPrice); //空头平仓 } }