Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Script | Magic Number Scorecard - win rate, profit factor and drawdown per EA | Source Code In…

RobotFX curates the best open-source MetaTrader code to inspire your trading automation.

Every Expert Advisor marks its trades with a magic number. Magic Number Scorecard groups the closed trades of the account by magic number, so you get one score line per EA (magic 0 = manual trades). It is a quick way to see which EA really earns, and which one only looks busy.

Image for Magic Number Scorecard - win rate, profit factor and drawdown per EA

For each magic number

Watch in-depth trading tutorials and EA reviews on the RobotFX YouTube channel. Subscribe for free tips.

  • trades, wins, losses and win rate
  • gross profit, gross loss and profit factor
  • net profit and average trade
  • best and worst trade
  • maximum drawdown of its closed-trade equity curve
  • symbols traded

The table is printed in the Experts journal, shown on the chart, and written to a CSV file in MQL5\Files that opens in Excel. The rows are sorted by net profit.

How the trades are counted

  • A trade is a closed position. All of its deals are added up: profit, swap, commission (entry and exit) and fee. A position closed in parts counts as one trade.
  • The owner of a position is the magic number of its opening deal, so an EA trade that you close by hand still counts for that EA.
  • Positions that are still open, fully or partly, are left out.

Inputs

Input Default Meaning
From / To 2000.01.01 / 0 history range, To = 0 means now
Only this symbol empty empty = all symbols
Write CSV file / CSV file name true / MagicScorecard.csv saved in MQL5\Files
Show the table on the chart true false clears the chart comment

Run the script on any chart. It only reads the account history and never trades.

Level up your trading with professional RobotFX expert advisors and indicators. Visit robotfx.org for proven MT4/MT5 tools.

78179

Best MetaTrader Indicators + Profitable Expert Advisors