Good Afternoon,
I'm currently working on my first EA and working with pre existing code. Here is the question, is there a simple relatively clean way to have the EA check open orders, and ensure that if it would not open another order on the same currency? The only way I can think of would be lots of if statements which seems like it would be highly inefficient.
For example if the EA were to take a long position on EURUSD, I want to ensure that it doesn't open anymore positions long or short on any pairs that have either the EUR or USD in them. I apologize in advance if this has been asked and answered.
Ahh so you dont like currency correlation...
You could make an array of open positions (of type Position or just use the integer ticket).
If there is a signal to open on EURCAD then you would loop through the array and check if any currently open positions were opened on EUR or CAD. Maybe using substrings?
If there are no positions using either of them then open the new position based on the signal and add it to the array.
Ahh so you dont like currency correlation...
You could make an array of open positions (of type Position or just use the integer ticket).
If there is a signal to open on EURCAD then you would loop through the array and check if any currently open positions were opened on EUR or CAD. Maybe using substrings?
If there are no positions using either of them then open the new position based on the signal and add it to the array.
Good Afternoon,
I'm currently working on my first EA and working with pre existing code. Here is the question, is there a simple relatively clean way to have the EA check open orders, and ensure that if it would not open another order on the same currency? The only way I can think of would be lots of if statements which seems like it would be highly inefficient.
For example if the EA were to take a long position on EURUSD, I want to ensure that it doesn't open anymore positions long or short on any pairs that have either the EUR or USD in them. I apologize in advance if this has been asked and answered.
Hello, I would like to check if you were able to code this specific array as I Couldn't achieve it as my programming knowledge is a not so high.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good Afternoon,
I'm currently working on my first EA and working with pre existing code. Here is the question, is there a simple relatively clean way to have the EA check open orders, and ensure that if it would not open another order on the same currency? The only way I can think of would be lots of if statements which seems like it would be highly inefficient.
For example if the EA were to take a long position on EURUSD, I want to ensure that it doesn't open anymore positions long or short on any pairs that have either the EUR or USD in them. I apologize in advance if this has been asked and answered.