Engineering notes

Engineering note · Trade history imports

Import MT4 History into Excel Without Losing the Evidence

An MT4 history import is ready for analysis when every included row can be traced back to its export and the totals reconcile. A searchable spreadsheet is useful, but it can still omit a month, count the same trade twice or treat a deposit as trading profit. Check those boundaries before ranking currency pairs.

  1. 01Freeze the export
  2. 02Keep row identity
  3. 03Reconcile totals
  4. 04Then compare pairs
Suggested review sequence for an MT4 history import. This is a data-design checklist, not a measured customer result.

Start with a defined export, not a screenshot

In the MT4 Account History tab, select All History or a documented custom period before saving the HTML report. The official help explains that the period filter uses closing time. An export of recently closed trades therefore answers a different question from an export of trades opened during the same dates. Write down which population you intend to analyse.

Keep the original report unchanged. Give the imported data a source-file field and record when the export was made. Use a local account alias rather than spreading account identifiers across working copies. The analysis needs reliable separation between accounts, not login credentials.

Before importing every account, inspect one representative file in Excel. Depending on the Excel version, use the available HTML or data-import route, or convert the table with a reviewed importer. Check the preview rather than assuming the first detected table contains only closed trades. A report can contain separate sections for closed transactions, open trades and working orders.

Decide what one row means

Use one row per exported trade record and retain the original ticket as text. Pair it with the account alias. A ticket alone is not a sensible cross-account identity. Keep the source row number as a separate audit field so a reviewer can find the exact line without guessing from the profit value.

Classify records before creating a pivot table. Closed buy and sell records belong in the trading-results view. Deposits, withdrawals and other balance movements need their own category. Open positions belong in a separate snapshot. Mixing these categories produces a plausible total with the wrong meaning.

Do not silently discard a row because it looks unusual. Keep an exceptions sheet with the source, reason and unresolved field. Partial closures and broker-specific comments deserve review against the actual export. Do not invent a parent-trade relationship that the source does not establish.

  • Identity: account alias, original ticket, source file and source row.
  • Context: broker/server label, account currency, symbol and record type.
  • Time: original open/close text plus the explicitly chosen parsed time convention.
  • Values: lots, prices, profit, commission, swap and any separately reported charges.

Parse time and money explicitly

A timestamp without a timezone is not a UTC timestamp. Preserve the original text and document the broker-time assumption. If you later compare sessions between accounts, require an evidenced conversion rule. Do not guess daylight-saving changes from the reader’s computer clock.

Check decimal separators, negative signs and empty cells before making the columns numeric. An empty commission cell is not automatically evidence of zero commission. Mark missing data explicitly and explain whether it prevents a complete reconciliation.

Keep original symbols alongside any reporting group. A suffix can identify a different broker instrument or account setup. Map symbols with an explicit lookup that a reviewer can inspect. Unmapped symbols should remain visible instead of disappearing from the summary.

Reconcile before asking which pair performed best

First compare included record counts and date boundaries with the retained export. Then compare monetary totals for the same account, currency and population. Keep trade profit and charges separately visible. MQL4 OrderProfit returns the selected order’s profit without swap or commission; an importer using that function must handle those fields separately. Do not subtract charges twice from a report field that already includes them.

Treat a difference as a finding to explain. Common checks include duplicated imports, missing periods, open records mixed with closed ones and an incorrect interpretation of charge signs. Keep the exception beside the total. Hiding it behind a rounded chart label makes the workbook harder to trust.

Only then create a pair-level view. Show the account, currency, observation period and number of included trades alongside the result. Accounts with different deposit currencies cannot be added into one currency total without an explicit conversion policy. A comparison of past records is not evidence that the best-looking pair will keep performing that way.

Make refreshes reviewable

Keep raw input, cleaned records, exceptions and presentation on separate sheets or queries. The refresh procedure should say whether a file replaces a previous snapshot or extends it. For overlapping exports, use a documented duplicate rule based on the account and trade identity, then check for conflicting versions of the same record.

A useful handoff includes the untouched sample export, field mapping, refresh instructions and expected results for the three checks below. These are proposed acceptance tests. They have not been run against a customer account here. The scope is a reliable history import, not live-account operation, tax reporting or a recommendation about what to trade.

Three acceptance checks

Proposed tests, not executed customer results. Record actual outcomes separately.

Known complete export

Input: Import a reviewed account report for one frozen period.

Expected: Every included trade traces to one source row; counts and same-currency totals reconcile, with all excluded categories listed.

Overlapping refresh

Input: Import the same file again, then another file with overlapping history.

Expected: Previously imported records are not counted twice. Changed versions are flagged under the documented conflict rule.

Malformed input

Input: Supply a row with an invalid timestamp, missing currency or unresolved numeric format.

Expected: The row appears in exceptions with its source reference. The summary visibly reports that reconciliation is incomplete.

Sources and related guides

For your own brief, write the starting state, expected behavior and evidence for each case. The free Bot Blueprint gives you a place to collect those requirements.

Trading risk disclosure

Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one's financial security or lifestyle. Only risk capital should be used for trading, and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical performance disclosure

Hypothetical performance results have many inherent limitations. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. There are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical results are generally prepared with the benefit of hindsight, do not involve financial risk, and cannot completely account for the impact of financial risk in actual trading. Market conditions, the ability to withstand losses, and adherence to a trading program can all materially affect actual results.

NinjaTrader trademark disclosure

NinjaTrader® is a registered trademark of NinjaTrader Group, LLC. No NinjaTrader company has any affiliation with the owner, developer, or provider of the products or services described herein, or any interest, ownership or otherwise, in any such product or service, or endorses, recommends or approves any such product or service.

Testimonials, when shown, may not represent the experience of other clients and are not a guarantee of future performance or success. Virtual-currency trading carries additional risks. See the CFTC customer advisories. Read the full financial risk disclaimer.