BigSnack, you use Ninja, right?
In their Indicators' forum, there's one that plots/targets HHs, HLs, etc. You could use that for the 2nd half of your strategy.
Also, you can hire a programmer who will happily give you a cleaner code in less time and in this economy will surely appreciate...