We present the DONUTS autoguiding algorithm, designed to fix stellar positions at the sub-pixel level for high-cadence time-series photometry, which is also capable of autoguiding on defocused stars. DONUTS was designed to calculate guide corrections from a series of science images and re-centre telescope pointing between each exposure. The algorithm has the unique ability of calculating guide corrections from under-sampled 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.