Artificial resistivity is included in Smoothed Particle Magnetohydrodynamics simulations to capture shocks and discontinuities in the magnetic field. Here we present a new method for adapting the strength of the applied resistivity so that shocks are captured but the dissipation of the magnetic field away from shocks is minimised. Our scheme utilises the gradient of the magnetic field as a shock indicator, setting {alpha}_B = h|gradB|/|B|, such that resistivity is switched on only where strong discontinuities are present. The advantage to this approach is that the resistivity parameter does not depend on the absolute field strength. The new switch is benchmarked on a series of shock tube tests demonstrating its ability to capture shocks correctly. It is compared against a previous switch proposed by Price & Monaghan (2005), showing that it leads to lower dissipation of the field, and in particular, that it succeeds at capturing shocks in the regime where the Alfven speed is much less than the sound speed (i.e., when the magnetic field is very weak). It is also simpler. We also demonstrate that our recent constrained divergence cleaning algorithm has no difficulty with shock tube tests, in contrast to other implementations.