Survival/README.md
2026-08-14 00:09:54 +00:00

44 lines
1.7 KiB
Markdown

# Survival
Survival analysis over your own MetaTrader 5 deal history. Answers how long
trades last and when they are most likely to die, which a win rate cannot tell
you.
Companion code for the MQL5 article: https://www.mql5.com/en/articles/23928
## What it does
A win rate collapses a trade's whole life into one bit. It cannot say whether
losers die early or bleed out slowly, whether an edge decays after a certain
holding time, or whether a stop is sitting in the worst possible place.
Survival analysis is built for exactly that question, and it handles censoring,
which is the part naive approaches get wrong. A trade still open when the
history ends has not "not failed". It is censored, and dropping it or counting
it as a survivor both bias the result.
The engine reads deal history into observations, then produces the Kaplan-Meier
survival curve, the hazard rate and the cumulative hazard from a single sweep.
`SurvivalPanel.mq5` draws them.
The article covers the edge cases, which is where this kind of analysis usually
goes wrong: partial closes, hedged positions and thin samples.
## Layout
```
Include/Survival/SurvivalTypes.mqh shared types
Include/Survival/TradeHistory.mqh deal history into observations
Include/Survival/SurvivalCore.mqh Kaplan-Meier, hazard, cumulative hazard
Indicators/Survival/SurvivalPanel.mq5 the panel
Experts/Survival/SurvivalDemo.mq5 demonstration expert
```
The panel reads your account's own history, so it needs deals to be present
before it shows anything.
## Disclaimer
Educational code. Past behaviour of any model or dataset says nothing about
future results. Test on your own data and broker conditions before drawing
conclusions.