% profit for all trades...
-
Hi guys i'm trying to make my EA to close all open trades once the total profit amount in % of the money account reaches 1 or 2 or 3%.
Let's say I have set the percentage at 2%. I have an account of 1000, my floating profit is +20 (equity 1020), 5 open trades. Then my EA must closes all 5 positions, waiting for the next condition to start again.
In check profit unrealized I see there's no option about % to close the trades. Nor in TP option under buy/sell blocks. So i tried with: bucket of trades (blue box) -> check profit (magenta box)->close trades

But i see there's something wrong because it closed my unique trade at 0.42 cents instead of waiting for 20$.
What's wrong: the method or "2" i put in the field?Thanks
-
There is no % option, but the option is in money... dollars. As you probably know, you can use native MQL functions in all input fields. So the default value is 0, but you can put something like:
AccountBalance() * 3 / 100.AccountBalance() gives you the current Balance, the amount of money you had before opening the trades. Let's say that the balance is 1000, then 1000*3/100 equals to 30 (dollars)

-
thank you
-
@fxdreema said in % profit for all trades...:
There is no % option, but the option is in money... dollars. As you probably know, you can use native MQL functions in all input fields. So the default value is 0, but you can put something like:
AccountBalance() * 3 / 100.AccountBalance() gives you the current Balance, the amount of money you had before opening the trades. Let's say that the balance is 1000, then 1000*3/100 equals to 30 (dollars)

Hi @fxDreema ,
Is there any way to do this so that the percentage figure is a Constant? (or some other method so it's available for optimisation) -
@drayzen said in % profit for all trades...:
3 / 100
just replace the "3 / 100" with your constant, type it there.
AccountBalance() * yourconstant -
Thanks again @roar ,
I was hoping Constants would be addressable like that, awesome!
Be good to add a note about this being possible here: https://fxdreema.com/help/working-with/constants-and-variables -
@fxdreema
Have experimented as follows, but after closing the trades often came out a minus. Please be so good and post here a fitting example of what this task exactly fulfilled.example
Trade 1 -12.25
Trade 2 + 5.25
Trade 3 +17.00
...........................
Total 10.00 -
@fxdreema said in % profit for all trades...:
AccountBalance() * 3 / 100.
AccountBalance () gibt Ihnen den aktuellen Kontostand, den Geldbetrag, den Sie vor der Eröffnung der Geschäfte hatten. Nehmen wir an, der Kontostand beträgt 1000, dann entspricht 1000 * 3/100 30 (Dollar)

how did you write that? with me always comes an error message
Sorry google translate