Used to happen to me quite frequently. But after I started being more generous in gap between pivot low and SL/TSL, it has reduced quite a bit. e.g. For NF, I put SL 5-6 points away from PL/PH, and if there is a round number (say multiple of 5), keep SL 3 points away from that as well.
I do this to prevent being SL hunted, but in your case, price didn't make HH after taking your SL. So yours was probably not the case of SL hunting, just a structure reversal and you would have anyways been taken out after price reversed from a LH later. I guess it couldn't have been prevented unless you book your position at some target.