I reckon the key to defining a setup is not to try and capture everything. There are many variations on any setup, which is why there is value in manual trading - we can discriminate visually between variations of a concept better than we can code them - so the key as in this case is being satisfied not to go after every M5 bar that breaks a H12 high or low, but only go after a specific subset that is describable with coding logic that can consistently discriminate that subset from all the other variations.
Unfortunately when we are looking at setups the ones that stick out as looking good visually are those that already match some level of confirmation bias we have developed after seeing something that looks good - we are not good at also looking for all those same setups or similar / slight variations that don't work well - so an important process is to also make sure our concept can discriminate against those as well.