I have this function which checks whether there are open trades using a certain magic number. The problem is I intend on using this EA for multiple currencies at once. Each order using a certain magic number depends on certain criteria being met but other criteria could appear in other currency pairs. How can I tailor this code to check magic numbers but only for the same currency pairs?
I would say the Solution in your problem is not in the code where when you are searching for the magic number; but rather how you create the magic number itself.
Per example: using 10000 as a base for this expert. Increments of 100 are used to identify the pair. (10100 EUR/USD, 10200, GPB/USD, and so on)
Then, when you want to look for all expert trades on different charts you use the range of the Magic Numbers. (Ex: 10000 to 11000).
That way, you can identify trade over all charts per ea, and the refine your search by pair.
There may be a better way to do it; but this is how I actually do it.
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum (2013)
PositionClose is not working - MQL5 programming forum (2020.02.21)
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles 2011
You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have this function which checks whether there are open trades using a certain magic number. The problem is I intend on using this EA for multiple currencies at once. Each order using a certain magic number depends on certain criteria being met but other criteria could appear in other currency pairs. How can I tailor this code to check magic numbers but only for the same currency pairs?