Dynamic beamforming is a wireless communication technique that enhances signal transmission and reception using multiple antennas to focus radio frequency energy towards specific directions or devices. Dynamic beamforming faces several challenges as mobility, signal interference, beam misalignment, beam training overhead, and signal traffic management. In this research work, an Advanced Optimized Algorithm (AOA) for beam-forming is proposed after a comprehensive analysis of the performance exhibited by the least mean square (LMS) and the Adaptive gradient algorithm. The weights of the antenna array are initiated and updated by the Advanced optimized algorithm, which involves moving in the direction of the negative gradient of the error signal. This optimization method significantly improves the array factor and the weighted value compared to the LMS and Ada-Grad algorithm, which reduce the processor burden and power consumption during the beamforming process. The outcomes of the experiments and analysis reveal that the proposed Advanced Optimized Algorithm is effective in enhancing the overall performance of beamforming patterns in the desired direction and can be used to resolve the issues of signal interference by employing complex weights for 5G antenna design. The proposed method demonstrates the suitability for high-speed, reliable real-time data communication, along with superiority for signal strength over the LMS and Ada-Grad algorithms.