Help required for a simple pair trading strategy

Hi

Can someone please help me with code for a simple pair trading strategy. Following is what I am trying to achieve

  1. I have a variable to find the relation between BHP and RIO. var = BHP close price / RIO close price
  2. I plot a Bollinger band around var with 20 day exponential average and 2 standard deviation
  3. I go long on BHP when var is below the lower Bollinger band and sell when var >= the upper band
  4. At the same time I go short on RIO when var is below the lower Bollinger band and cover when var >= the upper band

I will be grateful if someone can help with code. I case I have not given enough information or above is confusing please do let me know

Regards,

See this existing topic: How to do pair switching logic in AFL?

Thread was hijacked for completely unrelated matter. 2 posts were split to a new topic: Lost your shortcut