I assume you are using market orders in live trading based on how your code is written. That would explain being off one tick in some instances. If you have IOG=False, then if you generate orders at bar close, then the only opportunity for your generated order to fill would be on the next tick which is the open of the next bar.
I use IOG=True and my orders are written "buy next bar at market;" which results often in a delay of a few seconds until the next tick occurs even though I am buying via market I have to wait for the next trade to happen. I trade ZB which moves insanely slow compared to ES for example. But it's important to remember the tick that your system is evaluating is only used to generate orders. Once that order is generated the earliest it can fill is the next tick. Which can be bar open.
Apologies if I totally misunderstood what you are asking.
You are right about the bid/ask spread difference Tony, I pretty much want to preempt the close of the bar and enter at the price level the strategy intends, which is the ask of the close of the current bar before the next bar shows up 0.25 points away.
The current issue is trying to replicate strategy real-time performance as close to back-testing and walk-forward testing as is possible.
I have tried limit orders on a co-located server via MultiCharts but it still doesn't guarantee execution. ES uses a FIFO matching algorithm, so as a retail trader someone will always be faster using FPGA's or similar. I was hoping to use MultiCharts as a means to rapidly prototype strategies, that is get them working at a basic level of profitability and then perhaps port them to a low-level language and API to reduce latency and increase performance. However, I'm finding that replicating theoretical results in real-life is proving to be quite a challenge on the platform. Maybe I'm approaching things from the wrong perspective, but I'm starting to think I might be better off coding something custom in C/C++ to meet my exact criteria.