Loading…

Early Exit Cost Report

A trader who habitually takes profit early "to be safe" rarely sees the cumulative cost of that habit - each individual decision looks small, and MT4's history tab shows only what was actually earned, never what the original plan would have paid. This script makes that comparison directly, trade by trade and then totalled. For every closed winning trade that had a take-profit recorded, it prices what the distance from open price to that take-profit level was worth in account currency, using the symbol's own tick value and tick size rather than any assumed contract size. It compares that figure against what was actually earned. A trade only counts as an early exit if its close price landed away from both its own take-profit AND its own stop-loss - closing at (or effectively at) either one means the plan worked as designed, not that it was cut short. The comparison deliberately uses price-movement profit only on both sides (MT4's OrderProfit(), excluding swap and commission), because holding a trade to its original target would also have changed how much swap it accumulated - blending that into the comparison would silently misstate the number being reported. Notes and limitations - Only compares against the take-profit level recorded on the closed order. MT4 keeps no audit trail of take-profit modifications, so a target that was moved after entry is invisible here - the comparison is against whatever the last recorded take-profit was, not necessarily the original plan. - Trades with no take-profit ever set are excluded entirely, since there is nothing to compare against. - Losing trades are excluded - this report measures profit left on the table by winners, not what a loser would have done differently. - A trade that closed BETTER than its own recorded take-profit (for example, closed manually at a more favourable price during a fast move) is correctly excluded rather than reported as a negative cost.

Script · MT4 · v1.0 · Free

About Early Exit Cost Report

Early Exit Cost Report is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Price tolerance points, Max history to scan and Symbol filter. MQL source code included.

Files in the download: EarlyExitCostReport.mq4, EarlyExitCostReport.txt.

Settings

SettingDefaultWhat it does
Price tolerance points20Close price within this many points of TP/SL counts as "hit it", not an early exit
Max history to scan0Most recent closed orders to scan (0 = every closed order)
Symbol filter"" = every symbol, otherwise only this one

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria