Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Magic Number Inventory, Trade Logging and Classifying by Magic Number - script for MetaTrader 5

Seckin Erkut
Seckin Erkut
Algo Trading Systems Developer. I develop strategies and portfolios not by hypes but from solid academic literature.

I put my money where my mouth is, be sure to check the performance of my EAs through my signals.
Views:
48
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

If you run more than one Expert Advisor on the same account - or you trade manually alongside an EA - the account statement stops answering the question you actually have. The equity curve is a sum. It tells you the account made money; it does not  tell you which of your systems paid for the others, which one quietly stopped trading three months ago, or which one is carrying the whole result on its own. 


The magic number already contains that information. Every deal an EA places carries its magic, so the history is fully separable. This script does the separation and prints the table.

Load it on any chart of the account you want audited. It reads history only: it never opens, modifies or closes anything, and it does not need algorithmic trading to be enabled. The chart symbol is irrelevant - the whole account is scanned regardless of which chart the script sits on. Being a script, it runs once and removes itself.


WHAT IT PRINTS


One line per magic number, sorted by net result, best first, with these columns:

- trades      closed round turns (see the note on partial closes below)
- net P/L     realised result including swap and commission
- win%, PF    win rate and profit factor computed per round turn
- avgWin/Loss average winning and losing round turn
- open(vol)   positions open right now for this magic, and their volume
- pend        pending orders currently placed by this magic
- first..last first and last activity date
- symbols     instruments traded (truncated with "+" beyond three)

A totals row closes the table. Magic 0 collects manual trades and any EA that does not set a magic number - on most terminals that bucket is a mixture, not one system, so read it accordingly.

With InpExportCSV enabled (default) the same table is written to MQL5\Files\MagicInventory.csv for spreadsheet work.



TWO IMPLEMENTATION DETAILS THAT CHANGE THE NUMBERS


Both are easy to get wrong, and both are wrong in the direction that flatters you.

1. A partial close is ONE trade. A position closed in two parts produces    one entry deal and two exit deals. Counting exit deals would report two trades for one round turn - inflating the trade count, and worse, splitting a single result into a separate "win" and "loss" when the parts closed on opposite sides of breakeven. This script aggregates deals by DEAL_POSITION_ID first, so win rate and profit factor stay honest on scale-out systems.

2. Entry commission counts. On most commission-charging brokers half of the round-turn commission is charged on the entry deal, where DEAL_PROFIT is zero. A tool that reads closing deals only never sees it and overstates net P/L by roughly half the commission bill. Here every deal of a position contributes to that position's net.

Positions still open - and positions partially closed with a remainder still running - are not counted as trades, because their cost is not final yet. They appear in the open(vol) column instead.


HOW TO READ THE TABLE


- A magic with many closed trades but zero open positions and zero pendings has gone quiet. Either a filter is keeping it out of the market, or it stopped working. Check the last activity date.

- A magic whose entire net comes from a handful of large wins (high avgWin against a low win rate) is not necessarily broken, but its result depends on rare events - size it accordingly.

- Profit factor below 1.0 with a long history is a system paying rent. Profit factor above 2.0 on twenty trades is noise; wait for the sample to grow before believing either number.

- If two magics always show open positions at the same time on related symbols, you may be running one exposure under two names. The correlation between them is measurable - see the companion script Portfolio Correlation Analyzer, which computes exactly that on monthly P/L.


NOTES


- Only what the terminal holds is analysed. If the History tab is set to a short period, load "All history" (right-click in History -> All history) and run the script again.
- Deposits, withdrawals, credits and corrections are not trades and are excluded.
- Very old history without a position id is skipped rather than mis-counted.
- All output is read-only. The bundled guide covers installation and interpretation in more detail.

Structure Range Structure Range

Sell Arrow SL Box: Extends UPWARDS from the Sell Arrow. Buy Arrow SL Box: Extends DOWNWARDS from the Buy Arrow.

Scale Out Value Analyzer Scale Out Value Analyzer

A native MQL5 tool that reconstructs closed positions from deal-level history, flags the ones closed through more than one exit, and reprices each one at its own first, last, and best exit rates to measure whether scaling out actually added value. Reports a Value-Add Ratio, a Scale Out Win Rate, an Efficiency figure, and a single-trade dependence check, combined into an A+ to F score with recommendations. Runs out of the box against a built-in demonstration data set; a companion script exports the real input file from your own account history. Pure MQL5, no external libraries.

Daily Zone Recovery EA mt5 for GOLD Daily Zone Recovery EA mt5 for GOLD

Daily Zone Recovery is a multi-strategy trading expert advisor for MetaTrader 5 that operates based on the previous trading day’s high and low levels. The expert advisor monitors price behavior near daily extremes, uses three independent entry strategies, and can manage positions using a fixed-volume grid.

MACD Signals MACD Signals

Indicator edition for new platform.