How to improve indicator performance (speed)

 

Hi there,

Attached indicator is very slow as well. How can performance be improved?

Thanks in advance.

 
Pipanovic: Attached indicator is very slow as well. How can performance be improved?
It is very outdated code and calls itself recursively. It is in desperate need of being refactored and coded properly from scratch.
Reason: