Backtesting on XM MT5 vagueness bug ?

 
Hey, ive developped a simple EA based on ema's cross-over strategy and, even if i noticed a good efficiency reading these indicators on live market, ive tested my EA on XM MT5 with the backtesting to figure out that the results are pretty bad, because of opening trades when it shouldn't be the case and vice versa sometimes, here are some pics to show you my issue :  What should be What should'nt be What shouldn't be

Is it gona be only relative to the backtesting, or my settings are wrong ?

 
Fix your code.
 
Adren6 ive developped a simple EA … or my settings are wrong ?
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
 
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
I didn't send any code at first because I thought the issue came from the back-tester. I would have preferred that you ask it a nicer way though. Got the answer from another site. I fixed it by either selecting candle the previous candle(closed one/ID 1), or by applying the MA value to the open price instead of the close one, for those who have the same issue. 
 
The only thing that comes to mind is that you are using the most recent array data which differs after bar passed like <xyz[0]>... so in the strategy tester it seems like repainted transaction. FIX YOUR code is real. 99.99% the problem is with your code.