Define the start and finish of an episode
Track the running equity high and reset its observation index whenever equity reaches or exceeds that high. An episode begins when a later observation falls below it. Recovery occurs at the first observation reaching or exceeding the episode's starting peak. Completed duration equals (recovery index − peak index) × observation spacing. An unfinished episode uses (last index − peak index) × spacing and is marked still underwater. Duration therefore counts elapsed intervals, not simply the number of depressed observations.
Two underwater points can span three intervals
For daily equity observations 100, 90, 95, and 100, the peak is observation one, the trough observation two, and recovery observation four. The completed peak-to-recovery duration is three days, although only two sampled observations are strictly below the peak. If the record ends at 95 instead, the observed episode has lasted two days and is unresolved. Its ultimate recovery duration cannot be calculated from that truncated record.
Sampling and flows affect the history
A repeated value equal to the high resets the peak date, so time spent flat at the high does not count as a drawdown. Daily and weekly samples can miss different intraperiod peaks, troughs, or recoveries. Enter spacing that matches the observations; irregular dates require preprocessing rather than one average spacing. Deposits and withdrawals can falsely create peaks or recoveries in raw balances. An ongoing episode is right-censored, and comparing it directly with completed recoveries can understate its eventual length.