Closing all trades in one pair when target is met (equality?) when trading with multiple pairs
-
Hello,
I'm new to the whole trading business but have spent a lot of time the last couple of months getting to know the system and this program. I like working on a EA and learnt a lot from reading the forum an the tutorials.
The problem i'm having at the moment is that I want to close all trades in one pair when it hits a certain target. Lets say €50,-.
This is counted from the no trade point. so trades that have already closet count towards this target.Because I want to work with multiple pairs at once, the equality doesn't work for this as a condition. Somewhere on the forum I learnt that I can use the modify variables block to close all trades of all pairs when a certain profit is made. I'm using that as well.
Basically this is what i'm looking for:
Take profit : 50 pips per trade (know that one)
Close all trades of one pair: when target is met, say +500 pips in total per pair (don't know that one)
Close all trades of all pairs: when target is met, say +5000 pips in total over all trades, Equality. (I know how to do that one to)Thanks for reading and hope someone can help me with this.
-
Maybe this will help you - This checks for profit in money http://icecream.me/3c0204d7e5c57b6619d3346cb502e463
(Assign groups and symbol if you want it to become more refined.) -
Thank you.
I'm using profit in money in my ea at the moment. Thought it was easier to explain this way.
Now I know what I did wrong with the bucked trades.I was using the if trade block as a start. I assume this is not a block that cycles until there are no trades running, but only cycles once if there opens a trade?
Why are u using the per second block? Is this a better choice then the per tick block? Or is it just your preference? -
I use per second because i want it to check for profit every second until it reaches my desired TP. Ticks are unreliable in my opinion so i like this better... not sure if it is the right way but it works for me

-
@rnonnekes81 You tried some of those "Check profit..." blocks? Also those bucket blocks can be used, but you can easily use them in a wrong way. Can you make some simple EA that shows what is going on? I don't really understand that "no trade point" thing.
-
I see what you mean.
Will workout a ea this weekend when my day job is over.Hadees his solution works, but not completely. But that's because my explanation was not accurate enough.
thanks in advance
-
-
Ok, you have multiple pairs, many trades, only 1 Equity and 1 Balance value. You tried to compare different values and you don't like the result. This makes me think that the values you compared are not the right ones. Can you describe what value do you want to get?
That Bucket block is useless there. This block would make a list of trades, that's all. Then in another block you can get the results. See this:

In block 5 here only a list of Buy trades is created. Then in block 8 the count of these trades is calculated... and also other values (https://fxdreema.com/demo/mt4-bucket-trades)
The idea of those blocks is to be able to select group of trades, calculate some value out of them and use that value somewhere. -
I use "Check Profit (unrealized)" Block and "Close trades" Block to close all my open trades if my profit reach $5 for example
