Magic Number

 
I'd like to create a function which returns the number of trades using a specific magic number. Does anyone have ideas as to how that could be achieved? Not necessarily asking for specific code but possibly ways I could use existing mql4 functions. Thanks in advance
 
luxecapital:
I'd like to create a function which returns the number of trades using a specific magic number. Does anyone have ideas as to how that could be achieved? Not necessarily asking for specific code but possibly ways I could use existing mql4 functions. Thanks in advance

Hmm, You can actually find the idea you are looking for in almost every existing EA.

Just search "OrderSelect" and you will find what you want. unless I didn't undertand what you exactly want.

 

Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number/symbol filtering on your OrderSelect / Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
          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.

Reason: