Need Help With Currency Exposure Control
-
Hello. I have been struggling to implement the type of currency exposure I have used in manual trading:
This is what I currently have in place, and it stops trades from being entered if there is a trade involving one of the currencies, but this is not exactly what I'm trying to do: https://fxdreema.com/shared/QbCAvggdc
What I am looking for:
Lets say EA has two trades open on EURUSD (BUY) and has detected a buy opportunity on EURCHF (Buy).
A pre-check whereby EA will look for trades containing Buy exposure on the EURO and Sell exposure on the DOLLAR
then, the check will count the number of open trades (needs to be <=1 trade on the related pair),
the final check is such that if there exists one trade or less, that the Stop Loss is at or above breakeven
This is a diagram of the desired logic: https://fxdreema.com/shared/zuKoRd83b
This is the FINAL piece to my 5 year project so if ANYONE can help, I would very much appreciate it!
I hope I made sense and thank you in advance to any experts that can help me.
Faulknertrading1
-
I also want to add that I have been looking through the forums for a while on this particular issue, but either the solution makes no sense to me or the solution was not for exactly what I was looking for
-
@faulknertrading1 The problem is that part where you need to know the exposure on two different currencies (euro and dollar, for example). Are you planning to do it with many duifferent currencies at the same time?
-
Hello @l-andorrà and thanks for the response!
Yeah I plan to trade with the 8 Major Currencies + SGD.
I think the solution may have something to do with SymbolSelect() and SymbolName() but I wouldn't know where to start with implementing it -
@faulknertrading1 This would be quite difficult but, in a loop return symbol, cut to first or last 3, then add to variable, use this variable to confirm weather or not to continue. Set this up on a simple project and let me know if something's not working. (think if you search string cut MQL4 you'll find what you need)
-
@jstap said in Need Help With Currency Exposure Control:
string cut MQL4
@jstap
Thanks for responding.I'm a bit confused but I'm going to try what you have suggested, will post my attempt asap, thank you.
-
@jstap hello again, I have tried a few things but nothing is working for me.
I have tried this code on crypto pairs as it is weekend, but still I am unable to get the EA to perform as needed:
TradeFound = false; // reset
string name1 = StringSubstr(TradeSymbolName, 0, 3);
string name2 = StringSubstr(TradeSymbolName, 3, 3);// for each trade...
for (int i = 0; i < OrdersTotal(); i++)
{
// select the trade
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
// search
string tradeName1 = StringSubstr(OrderSymbol(), 0, 3);
string tradeName2 = StringSubstr(OrderSymbol(), 3, 3);if (tradeName1 == name1 || tradeName1 == name2 || tradeName2 == name1 || tradeName2 == name2) { TradeFound = true; } }}
I found this on a forum, and have a basic understanding of it, but could use some help on understanding what to do -
this is a link to what i have done so far https://fxdreema.com/shared/MIuAzaWee
-
@faulknertrading1 I had made a system exactly like this, but our hacker friend has destroyed it. Bummer.
The tricky part is always checking whether the currency is long or short. EURUSD buy trade has USD short component, USDJPY buy trade has USD long component.
What I did is, create some string arrays: one array for short currencies, one array for long currencies, and also arrays for trade counts.
-
@roar said in Need Help With Currency Exposure Control:
@faulknertrading1 I had made a system exactly like this, but our hacker friend has destroyed it. Bummer.
The tricky part is always checking whether the currency is long or short. EURUSD buy trade has USD short component, USDJPY buy trade has USD long component.
What I did is, create some string arrays: one array for short currencies, one array for long currencies, and also arrays for trade counts.
I just got all my projects back, at least it seems.
-
@tipsywisdom I have all shared projects, and own projects before July 2022
-
@roar @TipsyWisdom thank you for the responses and happy new year.
"What I did is, create some string arrays: one array for short currencies, one array for long currencies, and also arrays for trade counts." - This seems like the type of logic I'm looking for in my EA, and it and that hacker really messed things up for a lot of people, hopefully you are able to replicate/ recover your work. You probably know already, but the import function on fxD might help you?
I will the array angle my best shot when I get home from work. Any advice with creating arrays on fxDreema? I'm sure I can crack it with the forums but any help is appreciated.
-
@faulknertrading1 arrays can be created like this:

Then you can use all the basic array functions: https://www.mql5.com/en/docs/array
-
Hey again experts, I would like to share my progress so far and thank you for all the input so far. https://fxdreema.com/shared/9JGPwe8kd
I still could use some help with the following:
Isolating the Conflicting Trade Symbol somehow
loop the symbol of open trades and split them into their respective arrays. -
@roar "invalid array access"
lets say i load my ea on a symbol and it opens a trade then i change charts and it opens another trade on a symbol
how would i add each symbol to an array on trade?
-
@purelife173 What do you exactly mean by 'changing chart'? Are you removing the bot from chart 1 to activate it then on chart 2?
-
@l-andorrà no same chart window just changing the current symbol on the page
-
Then I'm afraid that goes beyond my capabilities, sorry. Maybe jstap can be more helpful here.