Schau, wie man Roboter kostenlos herunterladen kann
Finden Sie uns auf Twitter!
und werden Sie Mitglied unserer Fangruppe
Interessantes Skript?
Veröffentliche einen Link auf das Skript, damit die anderen ihn auch nutzen können
Hat Ihnen das Skript gefallen?
Bewerten Sie es im Terminal MetaTrader 5
Skripte

Trade History Exporter for MT4 - closed trades to CSV with costs, MAE and MFE - Skript für den MetaTrader 4

Daniel Reynolds
Daniel Reynolds
MQL4 and MQL5 developer building Expert Advisors, indicators, trade panels and utilities for MetaTrader 4 and 5.
What I build:
Ansichten:
76
Rating:
(1)
Veröffentlicht:
MQL5 Freelance Benötigen Sie einen Roboter oder Indikator, der auf diesem Code basiert? Bestellen Sie ihn im Freelance-Bereich Zum Freelance

MT4's Account History tab is hard to analyse. Trade History Exporter writes one row per closed trade to a CSV file you can open in a spreadsheet.

Columns: ticket, symbol, type, lots, open time, open price, close time, close price, points, profit, commission, swap, net, duration, stop loss at close, MAE points, MFE points, magic number and comment.

How the figures are worked out

  • A trade closed in several parts is one row. MT4 gives the rest of a part-closed trade a new ticket with the comment "from #..."; the script follows those links back to the first ticket, and only joins parts with the same symbol, side and open time. The close price is the lot-weighted average.
  • Commission and swap from every part are added up, so "Net" is the real result.
  • MT4 does not keep the stop loss a trade was opened with, so the file shows the stop loss at close (there is no R multiple column, because it could not be worked out honestly).
  • MAE (maximum adverse excursion) and MFE (maximum favourable excursion) are the largest move against and in favour of the trade, in points, from M1 bars. This is an approximation: the first and last minute can include prices just before the entry or just after the exit, and the bars are built from Bid prices, so for sell trades the spread is not included. MT4 keeps little M1 history, so for older trades they are left blank.
  • Brokers' archive summary rows (for example "Archived Transactions") are not trades and are left out; the report says how many.
  • Dates are written as yyyy-mm-dd hh:mm:ss (server time). The file is UTF-8 with a byte order mark. A comment that starts with =, +, - or @ gets a ' in front, so a spreadsheet does not run it as a formula.

Important: the script reads the history the terminal has loaded. In the Account History tab, right-click and choose All History first if you want everything.

Inputs

Trade History Exporter for MT4 inputs

The script's inputs

  1. Days back: 0 = all loaded history.
  2. Which symbols: all symbols or this chart's symbol only.
  3. Magic number: -1 = any, 0 = no magic number (usually manual trades), any other number = only that magic number.
  4. Work out MAE and MFE from M1 bars: true by default.
  5. File name.
  6. Save in the common Files folder (shared by all terminals) instead of this terminal's MQL4\Files folder.
  7. Column separator: comma, semicolon or tab.
  8. Decimal comma: writes 1,0950 instead of 1.0950. Used only with the semicolon or tab separator.

When it finishes, a message shows the file's full path, the number of trades, the number of winners, the net result, and how many rows were left out and why.

Currency Strength Free MT4 - Eight Currency Scanner Currency Strength Free MT4 - Eight Currency Scanner

Free MQL4 currency-strength dashboard with eight major currencies, ranking across up to 28 FX pairs, broker-symbol discovery and closed-bar data-quality checks. Standalone MIT-licensed source; no trading operations.

Trade Journal Trade Journal

An advanced MT4 trade journal featuring automatic CSV logging, detailed performance statistics, per-symbol analytics, searchable trade history, and comprehensive CSV reports.

Three Colors Three Colors

Example: Moving Average indicator filling by different colors

MACD Sample MACD Sample

Classical MACD Sample.