Usual suspects on this issue for me are usually:
1. “Position Size Shrinking” is not enabled. On the very last possible trade out of all trades in the list (i.e. 39 out of 40, or 19 out of 20, or 9 out of 10 etc). If the full amount of funds are not available to trade the next possible position in the trade list, Amibroker will assume that last position couldn’t have been taken and won’t make the trade.
2. Amibroker assuming you had fills on the orders that hit your LMT price after the 3.45pm cutoff (or whatever time you have set for the “Cancel Orders” time). Look at time and sales or a simple minute bar plot for the days’ trade. At what time of day did that one ‘missed’ trade hit your limit price? If it is after 3.45pm, then yes, Amibroker will assume you got the fill when in reality you wouldn’t have gotten the fill in real trade. Unfortunately this problem will not be able to be beaten at this point in time as MOC orders need to be submitted by no later than 3.45pm.
3. Rounding of price to the nearest cent or tick size are not working well. When using the round() function make sure you put the + or the – symbol in the right place in the function to ensure you are rounding up or rounding down correctly to the nearest cent/tick.