Let (Bt)0≤t≤T be either a Bernoulli random walk or a Brownian motion with drift, and let Mt := max{Bs: 0 ≤ s ≤ t}, 0 ≤ t ≤ T. In this paper we solve the general optimal prediction problem sup0≤τ≤TE[f(MT − Bτ], where the supremum is over all stopping times τ adapted to the natural filtration of (Bt) and f is a nonincreasing convex function. The optimal stopping time τ* is shown to be of ‘bang-bang’ type: τ* ≡ 0 if the drift of the underlying process (Bt) is negative and τ* ≡ T if the drift is positive. This result generalizes recent findings of Toit and Peskir (2009) and Yam, Yung and Zhou (2009), and provides additional mathematical justification for the dictum in finance that one should sell bad stocks immediately, but keep good stocks as long as possible.