I am currently working on a contest algorithm which is supposed to use a long short momentum strategy according to the 26 and 12 day exponential weighted moving averages. It was working great but when I tried changing my re balance section around based on a reading I saw, I started getting errors starting when I try to re-balance. I have been unable to figure this out so I figured I would stop being stubborn and just ask for advice. Let me know what you guys think. Any advice would be greatly appreciated!