Position Ageing Heat Lines
"How long should I hold this" is usually answered with a guess. This indicator answers it from the trader's own closed-trade history instead: it scans closed orders on the chart symbol, takes the median holding time of the WINNING ones (a robust figure a couple of outlier week-long holds cannot distort the way a mean would), and uses that as the "optimum holding window" for colouring every currently open position's line. A position younger than half the optimum is drawn cool blue, up to the optimum is green, up to 1.75x the optimum is orange, and beyond that is red - "overdue" in the plainest sense: this account's own history suggests winning trades on this symbol don't usually take this long. The bands are proportional to the computed optimum, not fixed hour counts, so the same colouring logic makes sense whether the trader's edge plays out in fifteen minutes or three days. When there is not enough closed-trade history yet to trust a computed median (fewer than a configurable minimum number of winners), it falls back to a plain user-typed hours figure rather than drawing a misleading colour scale from three data points. Notes and limitations The optimum is computed from WINNING trades only, on the chart symbol, on this account's local closed-order history (the terminal's own history, not a broker-wide figure) - a fresh account, a demo reset, or a symbol just started has no history to draw on and will show the fallback value until enough winners accumulate. "Median holding time of winners" is a heuristic, not a statistically rigorous optimal stopping calculation. It says how long winning trades on this account have TENDED to take, not a provably optimal exit time; a strategy still developing its edge may see this figure swing as more history accumulates. Up to 200 simultaneously open positions are tracked (MAX_TRACKED_LINES); this comfortably covers realistic manual and semi-automated trading, but a bulk grid/ martingale system opening hundreds of tickets on one symbol would exceed it. Lines are drawn only for the chart's own symbol - open positions on other symbols are not shown; attach a copy of the indicator to each symbol's chart to cover a portfolio.
Indicator · MT4 · v1.0 · Free
About Position Ageing Heat Lines
Position Ageing Heat Lines is an indicator for MetaTrader 4. It has 12 settings, such as Min winners for stats, Fallback optimum hrs and Cool band. MQL source code included.
Files in the download: PositionAgeingHeatLines.mq4, PositionAgeingHeatLines.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Min winners for stats | 8 | Minimum closed winning trades on this symbol before trusting the computed optimum |
| Fallback optimum hrs | 6.0 | Optimum holding hours to use when history is too thin |
| Cool band | 0.5 | Age <= optimum * this fraction is drawn "cool" (blue) |
| Warm band | 1.0 | Age <= optimum * this fraction is drawn "warm" (green/gold boundary) |
| Hot band | 1.75 | Age <= optimum * this fraction is drawn "hot" (orange); beyond is "overdue" (red) |
| Colour cool | clrDodgerBlue | Colour on the chart |
| Colour warm | clrLimeGreen | Colour on the chart |
| Colour hot | clrOrange | Colour on the chart |
| Colour overdue | clrRed | Colour on the chart |
| Line width | 2 | |
| Show label | true | Show age/optimum text at the line's right edge |
| Magic filter | -1 | Only show positions with this magic number, -1 = show all |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: MT4 Indicator · MQL4 Source Code