Loading…

Holding Time Distribution Report

Every trader has a theory about their own holding time - "my scalps bleed me dry" or "I should cut trades faster" - and almost nobody has checked it against their own history. This script does the check: every closed market trade is sorted into one of six bands, from under five minutes to over a week, and each band gets its own trade count, win count, win rate and net result. The bands are fixed, not typed in as free text. A free-text list of cut-offs invites gaps, overlaps and boundaries entered out of order, and a script that can silently misreport its own buckets is worse than useless for something meant to correct a trading habit. Six bands cover the range a retail account actually trades in, and the table has the same shape on every run, which matters when you are comparing this month against last month. Net result follows the same definition used across this catalogue: profit plus swap plus commission, not the raw price result alone. A trade that shows a small price gain can be a net loser once carry is counted, and burying that inside "the fast trades made money" would defeat the point of the report. Notes and limitations - Market trades only. Pending orders never reach closed history as filled trades and are not part of this report, on either platform. - The six band boundaries are fixed in the source as an array at the top of the file. Changing them means editing and recompiling; there is no input for it, deliberately, so a saved CSV always means the same thing. - Holding time is wall-clock time between open and close, not time the market was actually open - a position held over a weekend counts the weekend. - A very small sample in a band (a handful of trades) can show an extreme win rate that will not hold up; the count column is there so that is visible rather than hidden behind a percentage. - On MQL5, if an entry deal has aged out of the terminal's locally stored history independently of its exit deal, the open-time lookup falls back to using the close time itself, which puts that trade in the shortest holding-time bucket rather than its true one. This is rare in practice - MetaTrader keeps entry and exit deals together - but is not physically impossible on a very old position.

Script · MT4 · v1.0 · Free

About Holding Time Distribution Report

Holding Time Distribution Report is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as From date, To date and Symbol filter. MQL source code included.

Files in the download: HoldingTimeDistributionReport.ex4, HoldingTimeDistributionReport.mq4, HoldingTimeDistributionReport.txt.

Settings

SettingDefaultWhat it does
From date0From close time (1970.01.01 = no lower bound)
To date0To close time (1970.01.01 = up to now)
Symbol filterSymbol filter, blank = every symbol
Magic filter-1Magic number filter, -1 = every magic
Save csvtrueWrite the bucket summary to a CSV file
DelimiterDelimiterCommaCSV column separator

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: Scalping · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria