We performed transmission spectroscopy experiments on coplanar half wavelength niobium resonators at a temperature T=4.2 K. We observe not only a strong dependence of the quality factor Q and the resonance frequency f_res on an externally applied magnetic field but also on the magnetic history of our resonators, i.e. on the spatial distribution of trapped Abrikosov vortices in the device. We find these results to be valid for a broad range of frequencies and angles between the resonator plane and the magnetic field direction as well as for resonators with and without antidots near the edges of the center conductor and the ground planes. In a detailed analysis we show, that characteristic features of the experimental data can only be reproduced in calculations, if a highly inhomogeneous rf-current density and a flux density gradient with maxima at the edges of the superconductor is assumed. We furthermore demonstrate, that the hysteretic behaviour of the resonator properties can be used to considerably reduce the vortex induced losses and to fine-tune the resonance frequency by the proper way of cycling to a desired magnetic field.