You can either use AlgoVar, or a series. Both are asset linked. As far as I can see from the above code, most of those variables need not be static anyway.