The unscented Kalman filter (UKF) is a widely used nonlinear Gaussian filter. It has the potential to deal with highly nonlinear dynamic systems, while displaying computational cost of the same order of magnitude as that of the extended Kalman filter (EKF). The quality of the estimates produced by the UKF is dependent on the tuning of both the parameters that govern the unscented transform (UT) and the two noise covariance matrices of the system model. In this paper, the tuning of the UKF is framed as an optimization problem. The tuning problem is solved by a new stochastic search algorithm and by a standard model-based optimizer. The filters tuned with the proposed algorithm and with the standard model-based optimizer are numerically tested against other nonlinear Gaussian filters, including two UKF tuned with state-of-the-art tuning strategies. One of these strategies relies on online tuning and the other on offline tuning.