In agreement with a recent experimental discovery by Xi et al. (Phys. Rev. Lett., vol. 102, 2009, paper no. 044503), we also find a sloshing mode in experiments on the large-scale circulation (LSC) of turbulent Rayleigh–Bénard convection in a cylindrical sample of aspect ratio one. The sloshing mode has the same frequency as the torsional oscillation discovered by Funfschilling & Ahlers (Phys. Rev. Lett., vol. 92, 2004, paper no. 1945022004). We show that both modes can be described by an extension of a model developed previously Brown & Ahlers (Phys. Fluids, vol. 20, 2008, pp. 105105-1–105105-15; Phys. Fluids, vol. 20, 2008, pp. 075101-1–075101-16). The extension consists of permitting a lateral displacement of the LSC circulation plane away from the vertical centreline of the sample as well as a variation of the displacement with height (such displacements had been excluded in the original model). Pressure gradients produced by the sidewall of the container on average centre the plane of the LSC so that it prefers to reach its longest diameter. If the LSC is displaced away from this diameter, the walls provide a restoring force. Turbulent fluctuations drive the LSC away from the central alignment, and combined with the restoring force they lead to oscillations. These oscillations are advected along with the LSC. This model yields the correct wavenumber and phase of the oscillations, as well as estimates of the frequency, amplitude and probability distributions of the displacements.