This paper deals with the design of a controller possessing tracking capability of any realisable reference trajectory while rejecting measurement noise. We consider discrete-time-varying multi-input multi-output stable linear systems and a proportional-integral-derivative (PID) controller. A novel recursive algorithm estimating the time-varying PID gains is proposed. The development of the proposed algorithm is based on minimising a stochastic performance index. The implementation of the proposed algorithm is described and boundedness of trajectories and convergence characteristics are presented for a discretised continuous-time model. Simulation results are included to illustrate the performance capabilities of the proposed algorithm.