Loss Recovery Planner
This header answers one question honestly: at the SAME risk per trade that produced a loss, how many trades and roughly how many calendar days will it take a system with a given expectancy to earn that loss back. It does not answer "how do I get it back faster" by raising risk, because that question has a real answer only in the sense that raising risk raises variance and ruin probability precisely when an account can least afford it - and this header is deliberately not built to suggest that path. There is no risk-multiplier parameter anywhere in this file, on purpose. Every projection assumes constant risk throughout. EstimateRecoveryPlan divides the loss by the per-trade expectancy to get a trade count, and converts that into a day count using a caller-supplied trade cadence. When expectancy is zero or negative, the function does not degrade gracefully into a wrong number - it reports isRecoverable = false and a note stating plainly that the loss cannot be recovered from at this expectancy, and that the strategy's edge needs fixing first, not its position size. BuildRecoverySensitivityTable runs the same projection across a set of win-rate scenarios supplied by the caller, holding average win/loss size, the loss amount, and trade cadence fixed. A single-point projection invites false confidence that a specific number of trades is "the" answer; the sensitivity table shows how quickly that answer degrades as the win-rate assumption worsens, including the exact point where it flips to unrecoverable - the included demo deliberately spans that boundary. Self-contained: no order, position or account calls, no state carried between calls. Every function takes plain numeric parameters and returns a plain result. Notes and limitations - This header will never accept or compute a risk-multiplier, and none should be added to it in any future revision - constant risk is the whole point of the projection, not an incidental default. - estimatedDaysToRecover is a simple trades-needed / tradesPerDay division; it assumes a roughly steady trade cadence and does not model variance, losing streaks within the recovery period, or weekends/holidays. - expectancyPerTrade and avgWin/avgLoss must already be measured AT the same risk level the account will keep trading at - this header does not verify that consistency, it trusts the caller's inputs. - A recoverable projection is a best-estimate average, not a guarantee - actual trade sequencing can finish faster or slower than the estimate even with a genuinely positive expectancy. - No thread or state concerns: every function is pure arithmetic.
Script · MT4 · v1.0 · Free
About Loss Recovery Planner
Loss Recovery Planner is a script for MetaTrader 4. MQL source code included.
Files in the download: LossRecoveryPlanner.mqh, LossRecoveryPlanner.txt, LossRecoveryPlannerDemo.mq4.
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Risk & Lot Size · MT4 Script · MQL4 Source Code