Hi everyone! I'm working on a pairs trading strategy (based on a Udemy course) and I can't figure out where I am going wrong? The premise of the strategy is simple. Calculate the z-score based on a moving average (of the pair ratio [stockprice1/stockprice2]), then either go long (zscore2) the pair. Then the exit strategy is to get out of the trade when the zscore crosses zero. It shouldn't be too hard to create, but I can't figure out where I am going wrong. I think my orders are being calculated wrong. Thanks in advance for any help.