Looks ok to me. But it should not produce a too good backtest. Can you contact Support with that script? They'll check what the problem is, and will send you a fix if it's backtest bias.