We present the DONUTS autoguiding algorithm, designed to fix stellar positions at the sub-pixel level for high-cadence time-series photometry, and also capable of autoguiding on defocused stars. DONUTS was designed to calculate guide corrections from a series of science images and recentre telescope pointing between each exposure. The algorithm has the unique ability of calculating guide corrections from undersampled to heavily defocused point spread functions. We present the case for why such an algorithm is important for high precision photometry and give our results from off and on-sky testing. We discuss the limitations of DONUTS and the facilities where it soon will be deployed.