代码编写

////////////////////////////////////////////////////////////////////////////////////////////////////////// if (data1.MarketPosition>0) { if (data1.high>=destprice) { data1.sell(0, destprice); } if (stoplost>0) { stopprice = data1.EntryPrice-stoplost*minp; if (data1.close<=stopprice) { data1.A_DeleteOrder(); data1.sell(0, stopprice-minp*exoff); } } else if (data1.barssincelastentry==1) { stopprice = data1.low[1] - minp; Commentary("止损价 = " + text(stopprice)); } if (stoplost==0 and data1.barssincelastentry>=1 and data1.low<=stopprice) { data1.A_DeleteOrder(); data1.sell(0, stopprice-minp*exoff); } } else if (data1.MarketPosition<0) { if (data1.low<=destprice) { data1.BuyToCover(0, destprice); } if (stoplost>0) { stopprice = data1.EntryPrice+stoplost*minp; if (data1.close>=stopprice) { data1.A_DeleteOrder(); data1.BuyToCover(0, stopprice+minp*exoff); } } else if (data1.barssincelastentry==1) { stopprice = data1.High[1] + minp; Commentary("止损价 = " + text(stopprice)); } if (stoplost==0 and data1.barssincelastentry>=1 and data1.high>=stopprice) { data1.A_DeleteOrder(); data1.BuyToCover(0, stopprice+minp*exoff);

您好!图表指令(Buy/Sell指令)是无法实现您想要的挂单的结果,这个是由图表指令的性质决定的。因为图表指令默认是一定能成交的,回测的绩效也是基于这个前提来做的。所以,写法错误的策略有可能存在偷价、未来函数等问题,那都是因为这图表指令是一个理论值。这也是为什么您的开仓指令还没有成交,平仓指令照常发出的原因。