Same EA on multiple charts (different currencies) + Conditions (to open an order) achieved same time in multiple charts. Problem: Send only one order and not one order per chart
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everyone,
I decided to write my problem here hopefully someone help me because I am literally blocked. I spent a lot of time without any good results.
As written in the title, I have the exact same EA (MQL4) run on multiple charts (different currencies). The EA send an order when X conditions are met. Part of that condition is that only one order be open in all currencies. Unfortunately, it opens multiple orders from the different currencies when the conditions are met in the exact same time.
EA code (Demonstration): (Conditions are: seconds over 0 -I will change it later on when I fix my problem-, Once5 variable so it only sends one order in the current currency, HELP_HERE_MAYBE is where I tried various solutions)
The various solution I tried are different functions starting with:
- CountingAllPositions(). Problem: Conditions are met the exact same time so it returns 0 and I end up with 6 orders from all the six currencies
- OpenTrades(). Problem: Putting EA to sleep in a currency isn't efficient because sometimes it opens multiple orders because EA in EURUSD for instance runs exact same time as in other currencies.
- Priority() in link with CountAllPositions. Problem: It doesn't work.. because it still opens multiple trades. Not 6 as before but at least 2.
Note: I read about MagicNumber however, I don't really see how it is useful in my case since it's different currencies charts and not same currency multiple charts.
Note2: I read something about Mutex but I found for MQL5 plus I really didn't understand how to use it.
Note3: I tried using GlobalVariables but things got really messed up because I didn't understand how do you set a global variable in the first place. (int X=GlobalVariableSet("X", 10);). Global Variable name is X and value is 10?!
I thank you in advance for taking the time to read my problem and direct me towards the solution.
Abdel