Alright, I looked it through again. I adjusted it to compare the lines with previous close, now it closes position once price touches the line. But if you compare the versions, you'll see the line has shifted by one bar. Closing, on the other hand, happens 0.5-1 bar earlier. I'll send v2 to your email!
The requested indicator is used as a stop indicator , the idea of it the previous N bars lows"to stop a buy position" and N bars highs to stop a sell position
I modified a Bands indicator, and that does EXACTLY what you wanted, just set it at "Close long at Lowe Band" and that's what it will do. I'll send Hi-lo Bands to your email too!
Final notes: PBV is still there, leave it as it is, I recoded it to be properly used. V2 is still a rough version (beta), I'm waiting suggestions if any, if you are happy with the version I can make it look nice (I'll substitute the phrase "moving average" with "Gann line").
Bands indi is final in my opinion, but if you have good ideas, let me know!