Currency exposure
-
Hi

I was wondering if there's a way that before entering a trade, the EA will check if there's an open position already with the same currency ? for example: Let's say that I'm already in a long position on EURUSD and then there's a signal to enter a trade on EURAUD. In that case, I want the EA to direct to a different block.Hope I was clear enough.
Thanks a lot.
-
Probably this thread will help.
https://fxdreema.com/forum/topic/8169/how-can-a-sl-based-on-currency-be-set-up/22
-
Thanks for your replay.
Unfortunately, that is not helping with my issue.
What I need is a block that checks if there is already an open trade with one of the currencies, here is another example:
I have an open position on AUDUSD and now there is a signal to enter another trade on EURAUD.
It means that AUD is already on my open positions. I need the EA to recognise that condition so it could take different size on the next trade (with AUD).Hope it makes sense...
Thanks
-
I see. That is an interesting question. Honestly I don't know how to do it. Are roar or miro near here?

-
@shack11 we can store the 2 currencies into 2 variables, and then store the full symbol of each trade into 3rd variable, in a loop.
Then use StringFind function to search those 2 currencies from the full symbol string, for each trade.
The function returns -1 if it doesnt find a match.
https://docs.mql4.com/strings/stringfind -
I'll try that.
Thank you very much!
-
Once more, roar at the rescue! Impressive, once more.
BTW, what's the logic at using the yellow output of the 'For each trade' block? What is the opposite of 'For each trade? No trade, maybe?
-
@l-andorrà thanks. Its not opposite logic here, the yellow just activates after the loop work has finished. So the block first activates orange (for x number of times) and then it activates yellow.
Here's block info:

-
Four years here and this is tyhe first time I read it!!!

Thank you very much again.