We present a statistical technique which can be used to detect the presence and properties of moving sources contributing to a diffuse background. The method is a generalization of the two-point correlation function to include temporal as well as spatial information. We develop a formalism which allows for a derivation of the space–time two-point function in terms of the properties of the contributing sources. We test this technique in simulated sky maps, and demonstrate its robustness in identifying the presence of moving and stationary sources. Applications of this formalism to the diffuse gamma-ray background include searches for Solar system bodies, fast moving primordial black holes and dense cores of dark matter protohaloes in the solar neighbourhood. Other applications include detecting the contribution of energetic neutrinos originating in the Solar system, as well as probing compact objects in long-timeline lensing experiments.