What your looking for is probably called hammer/inverted hammer/hanging man or something like that.
That would be a good place to start--modifying that code. It's a bit different than these patterns: (reference noted at bottom)
Characteristics of the Pin Bar Formation
• The open and close of the pin bar are within the price range of bar 1 and bar 3 of the formation, or very close to being within their range.
• The open and close of the pin bar are very close together, the closer the better.
• The open and close of the pin bar are near one end of the bar, the closer to the end the better.
• The nose or tail of the pin bar sticks out from the surrounding price bars, the longer the nose of the pin bar the better.
Bearish Reversal Pin Bar Formation
In a top or bearish reversal pin bar formation the pin bar sticks out noticeably in between bar 1 and bar 3 and has a long protruding tail.
Bullish Reversal Pin Bar Formation
The bullish or bottom reversal pin bar formation is the opposite of the top reversal pin bar formation. Here again, we see the pin bar has a long protruding tail that has obviously rejected a certain price level.
Tradeable CandleStick Patterns - Links - Killer Forex Training Course - MicroTrends NinjaTrader