Your second function was not designed for Zorro. It is attempting to recalculate a value for every bar. In Zorro, you calculate an output once per bar instead. Rewrite it.