Why does back test never open trade at open price?

 

Hi

My code makes a decision at the close of a candle and trades immediately using every tick but it never gets the open price it always gets a price half way down or more of the new candle. Surely if the decision is made at the candle close the trade should be done before the next candle is open and should get the open price plus spread. In this screen shot example it is 10 points away. Can anybody explain this?



Thanks

 
You should check it's behavior in Visual Mode... it's always amazing to see how things can go different from expected :)
 
Zypkin:
You should check it's behavior in Visual Mode... it's always amazing to see how things can go different from expected :)

Thanks Mr Zypkin I watched the visual mode in slow motion and there was 6 ticks before the trade so then it was a case of finding out why there was no trade for 6 ticks. I found the test for candle close was inside another test that held off the trade until a condition was met hence the delay. Unfortunately I have the mindset of distrusting the back tester because it has been so unreliable giving different results for no reason. I think there is a compromise to be applied to the back tester in that it does work correctly on the data it is given however the data initialisation and acquisition is flaky to put it mildly.

Reason: