EA not closing trades fast enough

 
My EA is set to close a trade when the 5 ma with a 1 shift crosses the 5 ma with 0 shift. in the data window in my screenshot, the top value for the MA's is the one with the shift. The bottom value has no shift. When in a buy position, it should close a trade when the MA with a 1 shift is greater than the MA with no shift (so the top number should be more than the bottom) but it's not working right. Thinking there is either a problem with my code or could it be because my computer can't run the code fast enough? Attached is a screenshot of when it should've closed a trade but didn't and also a pic of my current closing system. Any help is much appreciated.
Files:
 
Luke Ferachi: My EA is set to close a trade when the 5 ma with a 1 shift crosses the 5 ma with 0 shift. in the data window in my screenshot, the top value for the MA's is the one with the shift. The bottom value has no shift. When in a buy position, it should close a trade when the MA with a 1 shift is greater than the MA with no shift (so the top number should be more than the bottom) but it's not working right. Thinking there is either a problem with my code or could it be because my computer can't run the code fast enough? Attached is a screenshot of when it should've closed a trade but didn't and also a pic of my current closing system. Any help is much appreciated.

I would say with 99% probability that it is your code that has bugs.

Even on an old PC with a slow network connection, a close operation under normal market conditions on MT4 should never take longer than a few seconds at most (unless it was a "news" event taking place at that moment).

Given that you did not provide the source code, nor log entries showing the activity, that is about the most we can say about your issue.

 
Fernando Carreiro #:

I would say with 99% probability that it is your code that has bugs.

Even on an old PC with a slow network connection, a close operation under normal market conditions on MT4 should never take longer than a few seconds at most (unless it was a "news" event taking place at that moment).

Given that you did not provide the source code, nor log entries showing the activity, that is about the most we can say about your issue.

Really didn't want to share my whole code due to others copying it so is there any other information I can give you that would help out? Also, thanks for the quick reply!
 
Just solved it...had a hidded "return;" in there that wasn't letting it close right.
 
You are welcome and congratulations on resolving it on your own.
Reason: