模拟账户执行止损问题

如下代码用IF888跑回测的时候会执行止损,但是跑模拟账户的时候就不会执行止损,请老师帮忙看看代码有啥问题,谢谢!Params Numeric mystoplossset(20); Numeric Fastlength(12); Numeric Slowlength(26); Numeric MACDlength(9); Vars Series<Numeric> EMA12; Series<Numeric> EMA26; Series<Numeric> MACDDiff; Series<Numeric> MACDDea; Series<Numeric> MACD; Series<Numeric> openprice; Series<Numeric> stoplossprice; Series<Numeric> mybuyprice; Series<Numeric> mysellprice; Series<Numeric> mystoplossprice; Bool conCrossOver; Bool conCrossunder; Events OnBar(ArrayRef<Integer> indexs) { Range[0:0] { EMA12 = XAverage(Close,FastLength); EMA26 = XAverage(Close,SlowLength); MACDDiff = EMA12 - EMA26; MACDDea = XAverage(MACDDiff,MACDLength); MACD = MACDDiff - MACDDea; openprice = open; conCrossOver = crossover(MACDDiff[1],MACDDea[1]); conCrossUnder = crossunder(MACDDiff[1],MACDDea[1]); //买入条件 if(Marketposition <>1 and conCrossOver) { Buy(1,openprice); mybuyprice = openprice; stoplossprice = mybuyprice - mystoplossset; buycount = buycount + 1; Print(\"购买序号:\"+text(buycount)+\", 价:\"+text(mybuyprice)+\", 量:1, 止损价:\"+text(stoplossprice)); } //止损条件 if(marketposition >= 1 and stoplossprice >= low) { Sell(1,min(open,stoplossprice)); mystoplossprice = min(open,stoplossprice); stoplosscount = stoplosscount + 1; PLa = mystoplossprice - mybuyprice; Print(\"止损序号:\"+text(stoplosscount)+\", 价:\"+text(mystoplossprice)+\", 量:1,单次亏损:\"+text(PLa)); } //卖出条件 Else if(marketposition >= 1 and conCrossUnder) { Sell(1,openprice); mysellprice = openprice; PLb = mysellprice - mybuyprice; sellcount = sellcount + 1; Print(\"卖出序号:\"+text(sellcount)+\", 价:\"+text(mysellprice)+\", 量:1,单次盈亏:\"+text(PLb)); } } }

建议投稿处理