实盘时出现了信号闪烁问题,求老师解答
实盘(模拟账户)时出现了信号闪烁问题,程序发出了平空委托,但再次打开程序的K线信号图时,平空信号却消失了。 一、先上代码: Global Numeric BuyLine; Global Numeric SellLine; OnInit() { SubscribeBar("000300.SSE","1d",20220901);//订阅沪深300指数(000300.SSE)日K线行情 SubscribeBar("000300.SSE","5m",20220901);//订阅沪深300指数1分钟K线行情 SubscribeBar("IF888.CFFEX","5m",20220901);//订阅沪深300期货1分钟K线行情 } Range[2:2] { If(data1.High > BuyLine AND time >= 0.1 AND time <= 0.143 and BarsSinceToday>0) { If(MarketPosition==0) { Buy(lot,max(open,BuyLine)); data1.PlotString("Buy","多",low,red); } Else if (MarketPosition==-1) { BuyToCover(lot,max(open,BuyLine)); Buy(lot,max(open,BuyLine)); data1.PlotString("Buy","反多",low,red); } } else If(data1.Low < SellLine and Time >= 0.1 and Time <= 0.143 and BarsSinceToday >0) //当向下突破并且无多单时,开空单 { If(MarketPosition==0) { SellShort(lot,min(open,SellLine)); data1.PlotString("Sell","空",high,Green); } Else if (MarketPosition==1) { Sell(lot,min(open,SellLine)); SellShort(lot,min(open,SellLine)); data1.PlotString("Sell","反空",high,Green); } } Else if (data1.Low[1] >= SellLine and data1.High[1] <= BuyLine and time==0.1 AND MarketPosition<>0) //如果在10:00分没有向上或向下突破,且昨日有持仓,则平仓 { If(MarketPosition==1 and BarsSinceEntry >0) { Sell(lot,Open[0]); data1.PlotString("Cover","平多",high,Yellow); } Else If(MarketPosition==-1 and BarsSinceEntry >0) { BuyToCover(lot,Open[0]); data1.PlotString("Cover","平空",low,Yellow); } } } 如上图的红色代码所示,当10:00时由于上一根bar的最高点和最低点没有突破区间,则要进行平仓操作,如下图所示: 这里有两个问题,求老师解答: 1、为什么9:59:59秒就发出了委托单? 2、平仓信号出现后又消失了,这是为什么?是因为time的时候不对吗?是否要改成currenttime?抑或是其他原因?