Kept researching and found this article:
https://www.mql5.com/en/articles/112
Class `CPositionVirtualMagic` helps solve the issue by implementing a Virtual Position based on magic by reading the orders history.
Seems to have sorted things for me.
The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument
- www.mql5.com
In MQL5 we have a capability to assign a magic number to each pending order, in order to use this information to identify the order. This opens up the vast possibilities of interaction between different Expert Advisors, and the development of even more complex systems. In this article, I would like to inform the public about the undervalued...
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
Hi, I am trying to have multiple copies of the same EA run in the same symbol with different magic numbers.
I already found older topics that mention this but I did not find any solutions yet.
I want one EA to know if for his magic number he is bought or sold, for instance.
For this, I use:
What happens is that different EAs with different Magic Numbers all see the same 1 position even if all of them have opened one independently. Then the Magic Number associated with that position seems to be either the first or last EA that created an order on that Symbol.
How can I decouple this so that one EA can easily tell if he is bought or sold, without needing to keep track of orders? I want to determine this programatically through MQL5's APIs in case I stop the bot and restart it with the same Magic Number, for instance.
Note: I need to know if THAT EA is bought or sold. It's possible one EA for that symbol is bought and another one is sold, for instance.
Am I missing something obvious?
I also already read about PositionSelectByTicket and similars but I still do not see how I should operate differently for EAs to see different positions for the same symbol. Is this possible or is there any different approach I could take?