If you look in the preMain() section you will see setComputeOnClose();. That is why it is not calculating on the current bar.
If you were to comment that line out, it would perform the calculation, however the calculation may not work correctly, since now you will be performing all those calculations every tick.
Try it and watch it a couple of bars, then reload it. If the history looks different, that means it will not work as written to do what you want.
Comment