I've figured out that the indicator is working fine until a new bar is formed, then the indicator is stopping. Can someone look at the code in the first post and see if they can fix this? It doesn't seem to be continuing when a new bar is formed.
Thank you to anyone that can help!