Code Library / Candlestick Patterns

Pine Script Hammer/Shooting Star

Detect hammer and shooting star reversal patterns.

Language: Pine Script · Category: Candlestick Patterns · Tags: hammer, shooting star, candlestick, Pine Script, reversal

Source code

//@version=5
indicator("Hammer/SS",overlay=true)
bs=math.abs(close-open); uw=high-math.max(close,open); lw=math.min(close,open)-low
ham=lw>bs*2 and uw<bs*0.5 and bs>0 and close<ta.sma(close,20)
ss=uw>bs*2 and lw<bs*0.5 and bs>0 and close>ta.sma(close,20)
plotshape(ham,"Ham",shape.triangleup,location.belowbar,color.green)
plotshape(ss,"SS",shape.triangledown,location.abovebar,color.red)

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets