@HPotter, Thanks for this script! Could you also help to convert this to //@version=4? For some reason Pine Editor returns "Syntax error at input 'end of line without line continuation" while using it in a strategy under version=4. If no version is mentioned, it works great!