历史回测,怎么是同时买入/平仓呢

//买入条件 entry_condition1 = MidLine[1] < MidLine[0]; entry_condition2 = CrossOver(kValue[0], DValue[0]); if( MarketPosition<>1 and entry_condition1 and entry_condition2) { buy(lots,Open); takeprofeprice = open+win*minmove*pricescale; stoplostprice = open-loss*minmove*pricescale; } PlotNumeric ("takeprofeprice ",takeprofeprice,0,Red); PlotNumeric ("stoplostprice ",stoplostprice,0,Green); //出场 how_S =T*60; for i=0 to how_S { if( MarketPosition == 1 and High>=takeprofeprice) { Sell(0,max(Open,takeprofeprice)); } if( MarketPosition == 1 and Low<=stoplostprice) { Sell(0,Min(Open,stoplostprice)); } } 历史回测,怎么是同时买入/平仓呢 实盘中,平仓作废 程序顺序,是先入场,后出场啊 该怎么改进呢?

历史回测,每一根bar只跑一次,用收盘状态下bar的数据来运行公式,如果同时满足了开平条件,就会标记开仓和平仓信号。 你策略的问题就在于,你的止损跳数对于你使用的周期来说太小了,导致同时满足条件。 你可以加上barssinceentry函数判断强制开仓bar不平仓 或者放大跳数 或者跨周期处理