EA Backtesting - Inconsistencies


Hello everyone,
I've written the attached EA with lot's of help from this forum for which I thank you all, and have started to backtest it and noted that orders (no matter the forex pair or timeframe) are opened and closed not according to the EA's coding. I'm attaching some .png to illustrate these errors and would very much appreciate any hints to clarify why this is happening to try to get to a solution.

Thanks in advance.