We study how the shape of a periodic magnetic field affects the presence of Majorana bound states (MBS) in a nanowire-superconductor system. Motivated by the field configurations that can be produced by an array of nanomagnets, we consider spiral fields with an elliptic cross-section and fields with two sinusoidal components. We show that MBS are robust to imperfect helical magnetic fields. In particular, if the amplitude of one component is tuned to the value determined by the superconducting order parameter in the wire, the MBS can exist even if the second component has a much smaller amplitude. We also explore the effect of the chemical potential on the phase diagram. Our analysis is both numerical and analytical, with good agreement between the two methods.