A local cross-validation algorithm for dependent data