You have it right, strip this back to a single condition, and back test, then add more conditions until you have what you want.
Move the once per bar under your conditions: 405af50f-a644-461d-861c-80681646b340-image.png