Close all trades not working
-
Hello!
I am trying to close all the trades when they are in total profit of 2 (e.g when your unrealized profit on the account is 2 so for example, the balance is 200 and the equity is 202, then all the trades including the losing ones should get closed)
I tried this out, but for some reason it does not work. Any help? Its in the "on tick" tab as well. I tried putting it into on trade as well, but nothing happened.
I have already browsed the forum and found similar issues, but when I implemented those solutions, they didnt work either.
-
@boferer Any help would be heavily appreciated!
It seems like my ea cannot execute the check profit unrealized for some reason. Any idea why that is? -
Im thinking the EA doesnt know whats profit because it works on all occasions besides the one with profit
-
... hard to say what is wrong ... this is working:
https://fxdreema.com/shared/gSHV0yq5d -
@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 -
@boferer do you need a condition like once per bar or seconds as the first block for it to run ?
-
@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.
-
@boferer i check profit and close trades like this

-
@hadees Nope. Doesnt work unfortunately. We need to somehow define the profit. I think the EA does not know what the profit truly means.
-
@boferer within the block you will need to make sure it is for buys and sells and then pick money as type of in profit. http://icecream.me/e1ba9a0b666f6ecefc8f2b3af714f484
-
@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
-
@boferer Still didnt manage to find the mistake..
-
I think, you have no idea what are you doing. Your looking on the equity line vs balance line is not right. The X axis are trades one after another and not the time (for MT4). If you trigger the closing event, the portfolio of opened trades starts to close and the equity vs. balance starts to draw - each closed trade will be a new addition to the balance line. If a lossable trade was closed, the balance line goes down, or up if a profitable was closed. If you want more details in the X axis (the time), use MT5 for testing. Notice, that there will be the same movement with the balance line when a lossable or profitable trade is closed.
https://fxdreema.com/shared/2TVhajb9

The Check profit block for both (MT4 and MT5) is working right.
Note that the trades opened manually have the magic number 0 (set your in the EA settings the Magic to 0). Or alternatively set the right Group mode in all the blocks.
-
@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.
-
run this in the MT5 tester and check how is it working (equity, balance, etc.)
https://fxdreema.com/shared/HBENFiAT -
@miro1360 Will do!
-
@miro1360 Tried it and it didnt work..
Isnt there a way how to do this which is.....more simple? -
how are your trades opened? (by another EA? inside the same EA? manually?)
-
-
@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.