I think its the other way round, you must use loop() for the advise calls. I dont understand why you use 2 loops. Invalid signal probably means you divide by zero.

https://manual.zorro-project.com/loop.htm