Okay! I think I found the culprit everyone. It was the floating spread which widened too much during some periods of the test thats why it didnt close
The solutions provided here do indeed work
Please, accept my sincere apology for the trouble and I thank wholeheartedly everybody who tried to help. It means the world to me.
Latest posts made by Boferer
-
RE: Close all trades not workingposted in Questions & Answers
-
RE: Close all trades not workingposted in Questions & Answers
@miro1360 As Iยดve sent in the screenshot above, they are all opened in the same EA. The same thing happened in MT5, trades are opened and then they do not get closed until the backtest is over. Also, there were more long trades open than short ones and the trend was bullish so it had to be in profit at some point. @ambrogio there are no buy/sell orders, only market orders which go through immediately. I have stopped the EA randomly during the tests to see if the thesis that they are not in a profit holds and the EA stopped in profit a couple of times when I stopped it so the argument that the trades are simply not in profit does not hold true in this case.
-
RE: Close all trades not workingposted in Questions & Answers
@miro1360 Tried it and it didnt work..
Isnt there a way how to do this which is.....more simple? -
RE: Close all trades not workingposted in Questions & Answers
@miro1360 Thank you for your reply Miro!
So what is it you are suggesting I should do to resolve the issue? Sorry if I misunderstood it, but its a lot to take in.
-
RE: Close all trades not workingposted in Questions & Answers
@boferer Still didnt manage to find the mistake..
-
RE: Close all trades not workingposted in Questions & Answers
@hadees I did, didnt work

Another thing I noticed is that when I approach the problem from a different angle and do condition balance is bigger than equity, then it triggers the close trades block, but when its reversed (e.g. equity is bigger than balance, then close) it wouldnt work.
However, it should be noted that your approached DID in fact trigger the blocks, but the desired function is still not there. The trades somehow close randomly (e.g. when the equity is even +7-14 the trades do not close sometimes)
Here you can see the visual and the equity line. The trades do not close when the equity is +2 above the balance, but rather close randomly it seems.
Would having in there something like this help? https://imgur.com/a/vBhaHGc
-
RE: Close all trades not workingposted in Questions & Answers
@hadees Nope. Doesnt work unfortunately. We need to somehow define the profit. I think the EA does not know what the profit truly means.
-
RE: Close all trades not workingposted in Questions & Answers
@hadees No, the ea is supposed to run every tick so I am not sure if I need it there or if its okay to leave it out.
-
RE: Close all trades not workingposted in Questions & Answers
@miro1360 Doesnt work
I dont seem to know why...maybe its because of MT4? I dont understand.This is what the whole ea looks like https://imgur.com/a/zwxAzlV
Cant wrap my head around whats wrong