MagicNumberInventory v1.00 - User Guide
========================================
"Who is trading on my account?" A read-only audit of everything that
has ever traded on the account, grouped by magic number.

WHAT IT DOES
------------
Scans the closed-trade history and prints one line per magic number:
round turns, net P/L (swap and both-side commission included), win rate, profit
factor, average win and loss, currently open positions (count and
volume), pending orders, first-to-last trade dates and the symbols
traded. Magics are sorted by net P/L, best first, with a totals row.
Magic 0 collects manual trades and EAs that do not set a magic number.

The script only READS. It never opens, modifies or closes anything and
needs no algo-trading permission.

INSTALLATION AND RUNNING
------------------------
1. Copy MagicNumberInventory.mq5 to MQL5\Scripts (File -> Open Data
   Folder), refresh the Navigator, compile once if edited (F7).
2. In Toolbox -> History, right-click and choose "All history" so the
   full record loads from the server.
3. Drag the script onto any chart and press OK.
4. Read the table in Toolbox -> Experts.

INPUTS
------
InpExportCSV (default true)
    Writes MagicInventory.csv (semicolon-separated) to MQL5\Files with
    the same columns as the log table - open it in any spreadsheet.

READING THE OUTPUT
------------------
- A magic with many closed trades but zero open positions has gone
  quiet - check whether that EA is still attached anywhere.
- Profit factor (gross profit / gross loss) below 1.0 with a large
  trade count deserves a hard look; with a small count it is noise.
- The symbols column shows up to three names, then "+" - use the CSV
  for the full picture.
- Open positions and pendings are counted at the moment you run the
  script, so numbers change during the session.

NOTES
-----
- One position is one trade. A partial close produces several exit
  deals but is counted as a single round turn, so the trade count,
  win rate and profit factor are not inflated by scale-outs.
- Net P/L includes the commission charged on the ENTRY deal, not only
  the exit. Tools that read closing deals alone understate cost by
  roughly half the commission bill on most brokers.
- Positions still open, or partially closed with a remainder still
  open, are not counted as trades (their cost is not yet final).
- Deposits/withdrawals are not trades and are ignored.
- If the table looks short, the server likely sent a truncated
  history - repeat the "All history" step and rerun.

License: free to use, modify and redistribute. No warranty.
