The fifth generation (5G) network is an upcoming standard for wireless communications that coexists with the current 4G network to increase the throughput. The deployment of ultra-dense small cells (UDSC) over a macro-cell layer yields multi-tier networks, which are known as heterogeneous networks (HetNets). HetNets play a key role in the cellular network to provide services to numerous users. However, the number of handovers (HOs) and radio link failure (RLF) greatly increase due to the increase in the UDSC in the network. Therefore, mobility management becomes a very important function in a self-organizing network to improve the system performance. In this paper, we propose a velocity-based self-optimization algorithm to adjust the HO control parameters in 4G/5G networks. The proposed algorithm utilizes the user's received power and speed to adjust the HO margin and the time to trigger during the user's mobility in the network. Simulation results demonstrate that the proposed algorithm achieves a remarkable reduction in the rate of ping-pong HOs and RLF compared with other existing algorithms, thereby outperforming such algorithms by an average of more than 70% for all HO performance metrics.