I am new to pairs trading and am in the process of constructing the code for backtesting a basic pair trading strategy. While I understand the basic idea behind the pair trading strategy, I am having trouble understanding which stock to short or long should future price dynamics change between the pair.
My question: Let say stock A currently trades at a price that is more expensive than Stock B. If this relationship continues to persist, whenever there is a divergence in price, I will short A and long B. But if price dynamics change such that price of B > price of A, I would need to switch between the entry such that when there is a divergence, I will need to now short B and long A.
Is this correct?