An automated method of controlling neural stimulation. A neural stimulus is applied to a neural pathway in order to give rise to an evoked action potential on the neural pathway, and the stimulus is defined by at least one stimulus parameter. A neural compound action potential response evoked by the stimulus is measured. From the measured evoked response a feedback variable such as observed ECAP voltage (V) is derived. A feedback loop is completed by using the feedback variable to control the at least one stimulus parameter value for a future stimulus. The method adaptively compensates for changes in a gain of the feedback loop caused by electrode movement relative to the neural pathway. A compensating transfer function is applied to the feedback variable, the compensating transfer function being configured to compensate for both (i) a distance-dependent transfer function of stimulation, and (ii) a distance dependent transfer function of measurement which is distinct from (i).