The prospects of active wake deflection control to mitigate wake-induced power losses in wind farms have been demonstrated by large eddy simulations, wind tunnel experiments, and recent field tests. However, it has not yet been fully understood how the yaw control of wind farms should take into account the variability in current environmental conditions in the field and the uncertainty in their measurements. This research investigated the influence of dynamic wind direction changes on active wake deflection by intended yaw misalignment. For this purpose the wake model FLORIS was used together with wind direction measurements recorded at an onshore meteorological mast in flat terrain. The analysis showed that active wake deflection has a high sensitivity towards short-term wind directional changes. This can lead to an increased yaw activity of the turbines. Fluctuations and uncertainties can cause the attempt to increase the power output to fail. Therefore a methodology to optimize the yaw control algorithm for active wake deflection was introduced, which considers dynamic wind direction changes and inaccuracies in the determination of the wind direction. The evaluation based on real wind direction time series confirmed that the robust control algorithm can be tailored to specific meteorological and wind farm conditions and that it can indeed achieve an overall power increase in realistic inflow conditions. Furthermore recommendations for the implementation are given which could combine the robust behaviour with reduced yaw activity.