Discussing the article: "Position Management: Deriving a Self-Calibrating Exit Ladder From Historical MFE in MQL5"

 

Check out the new article: Position Management: Deriving a Self-Calibrating Exit Ladder From Historical MFE in MQL5.

We implement three MQL5 classes that replace fixed 1R/2R/3R targets with data-driven scale-out levels. CExcursionTracker records each closed trade's maximum favorable excursion in R, CExitLadderCalibrator derives runs from distribution percentiles with lookback and minimum-sample controls, and CLadderExecutor executes them on open positions. The ladder recalibrates as trades accumulate and uses a fallback until enough samples exist.

When building an EA that scales out of positions, the practical question is not what looks nice, but when a trade has earned enough that part of it should be banked. This becomes an engineering problem the moment exits are automated across many trades, instruments, and stop sizes: a fixed rule such as take a third off at 1R, a third at 2R, let the rest run is convenient, but it is essentially a guess dressed up as a rule. On paper it reads as disciplined; in practice a strategy may almost never reach 3R, making the final rung mostly decorative, or it may routinely reach 5R, making a 2R rung a cap on the strategy's own edge rather than a target. ATR-based spacing helps by adapting to volatility, but it still says nothing about how far this specific entry logic, on this specific symbol, actually tends to run.

This article replaces the guess with a measurement-based pipeline suitable for production EAs. Each trade's maximum favorable excursion is measured in units of R—MFE-in-R, where 1R is the price distance between entry and the initial stop—those samples are persisted, and the most recent samples are turned into scale-out rungs computed from the account's own history rather than chosen by hand. "CExcursionTracker" records live per-ticket MFE-in-R and writes persistent samples; "CExitLadderCalibrator" converts the most recent N samples into percentile-based rungs with a configurable lookback, a minimum-sample threshold, and a fallback ladder; "CLadderExecutor" applies those rungs to open positions, handling volume rounding, per-ticket rung state, and an optional breakeven move. The result is a self-calibrating ladder, expressed in R, that can be plugged into any EA: a fallback ladder covers the account until enough history accumulates, after which percentiles over recent trades drive scale-out levels that reflect actual strategy behavior rather than a designer's guess.

Architectural overview of the system

Author: Tola Moses Hector