我设置的平仓时间是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); //空头平仓
}
}
中金所品种默认开平互转。买入平今空的委托会自动转成买入开多。平今多同理。
不想用这个功能节省手续费,可以在系统设置里关掉,不难找
非常感谢!