I was trying to replicate the example 3.1 from Ernest Chan's book 'Algorithmic Trading: winning strategies and their rationale' in Quantopian. It's basically a pair trading using Bollinger band. I used the same pair (USO/GLD) and the same parameters as in the example and I think I coded it right (maybe I missed something), but I cannot replicate the good results in the example. My results are very poor and I cannot figure out why. Could anybody kindly help?