Thank you all for the feedback, testing, and ideas regarding the SOT indicator.
I’ve corrected the mistakes based on your suggestions. I might still be wrong, so feel free to improve it further and share it here with everyone.
I’ve included both the .mq4 and .ex4 files.