Waveform inversion is the method of choice for determining a highly heterogeneous subsurface structure. However, conventional waveform inversion requires that the wavefield for each source is computed separately. This makes it very expensive for realistic 3D seismic surveys. Source-encoding waveform inversion, in which the sources are modeled simultaneously, is considerably faster than conventional waveform inversion but suffers from artifacts. These artifacts can partly be removed by assigning random weights to the source wavefields. We found that the misfit function, and therefore also its gradient, for source-encoding waveform inversion is an unbiased random estimation of the misfit function used in conventional waveform inversion. We found a new method of source-encoding waveform inversion that takes into account the random nature of the gradients used in the optimization. In this new method, the gradient at each iteration is a weighted average of past gradients such that the most recent gradients have the largest weights with exponential decay. This way we damped the random fluctuations of the gradient by incorporating information from the previous iterations. We compared this new method with existing source-encoding waveform inversion methods as well as conventional waveform inversion and found that the model misfit reduction is faster and smoother than those of existing source-encoding waveform inversion methods, and it approaches the model misfit reduction obtained in conventional waveform inversion.