I need help with a logic function

If you have two different currency pairs and their prices are different but you've noticed that they move in the same direction however sometimes one lags the other one or one leads the other one by few pips for few seconds. What function can i use to determine when one is leading/lagging? In mql5