Congestion detection in transmission control protocol/active queue management networks remains a challenging problem in which the choosing of congestion signal is one of the most important factors. Exponentially weighted moving average of queue length, the most widely used congestion signal, is facing difficulties in detecting incipient congestion and quantifying the optimal forgetting factor. Aiming at these 2 disadvantages, we propose an average queue-length-difference-based congestion detection algorithm where exponentially weighted moving average of queue-length difference is chosen as the congestion signal with the theoretical optimal forgetting factor deduced. First, by defining the queue-length difference as the state, the corresponding state equation is derived from the fluid model. Second, we prove that the inflow traffic in state equation is a discrete-time martingale, which can be transformed to a Wiener process according to the martingale representation theorem. Noticing that the observation of state will be coupled with noise because of the unstable transmission, the state estimation is then derived with the application of recursive least squares filter. The filter gain of state estimation, which is a function of the noise-signal ratio, corresponds to the optimal forgetting factor in average queue-length-difference-based congestion detection algorithm. Simulation results in NS-3 and MATLAB illustrate the effectiveness of the proposed algorithm.