Close position in $ pfoit including trading fees
-
Hi guys,
I am trying to make an EA close all positions when a certain money amount is reached. I want to include trading fees (swap and commissions) in the calculation. I cant get my head around why the EA does not close positions when the variable called "As_Money_Sum" (profit+fees) is above the money amount. Can anyone see what I am doing wrong? -
@piptheripper
https://fxdreema.com/forum/topic/13977/closing-an-order-always-with-a-positive-value/10
Hello friend, this is something old, I've been trying to get clear answers about it but I can't, I saw that there are other similar posts, I'm starting to believe that there isn't a solution and that the block isn't doing the correct calculation. -
@ontradingx

Try to use this.
" Block Close Profitable Position"
It's been working for me. -
@ontradingx Thanks for your inputs. That block will not work for my project, as I will close a basket of trades with a total sum profit, but not all of the positions will be in profit. It is a martingale type system..
-
@ontradingx I will post the solution here once I find it:)
-
@piptheripper great my friend, thanks i will wait this solution by @fxdreema
-
@ontradingx Here is a solution that works: https://fxdreema.com/shared/3Ltd8y7jc
Pay attention that some brokers charges half the commission when you enter a deal and the second half when you exit a deal. Most brokers charges half in and half out.
There are inputs where the user has to manually insert the commission his/her broker charges and how they are charged
Let me know if you have any questions.
-
@piptheripper Noticed an error. I forgot to set the divider to 2 if half commission is payed when opening and second half is payed when closing.. Just change it from 1 to 2
-
@piptheripper
Nice work friend, I'm going to test on my EA that it needs rate calculation to close positive or negative orders and return an answer.
Thank you for sharing. -
You are welcome. Pay attention that this only calculates commissions and not swap fees..