You can try to encapsulate your loop into a condition with “IsLastBarUpdate”, so that the code is only once each time the last bar is updated (new price received), see:
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue