// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kruskakli
//
// @description This indicator identifies Evening Star and Morning Star candlestick patterns
// @author Original: Robert N. 030715, Modified by Roo
//
//@version=6
indicator(title = "Candlestick Patterns", shorttitle = "Candles", overlay = true)
// Candlestick Patterns
isEveningStar=(close[2] > open[2] and math.min(open[1], close[1]) > close[2] and open < math.min(open[1], close[1]) and close < open )
isMorningStar=(close[2] < open[2] and math.max(open[1], close[1]) < close[2] and open > math.max(open[1], close[1]) and close > open )
isShootingStar=(open[1] < close[1] and open > close[1] and high - math.max(open, close) >= math.abs(open - close) * 3 and math.min(close, open) - low <= math.abs(open - close))
isHammer=((open[1]>close) and (low<low[1]) and ((high - low)>3*(open -close)) and ((close - low)/(.001 + high - low) > 0.6) and ((open - low)/(.001 + high - low) > 0.6))
isGravestone=(close<math.min(open[1],close[1]) and ((high - low)>3*(open -close)) and ((high - close)/(.001 + high - low) > 0.9) and ((high - open)/(.001 + high - low) > 0.9))
// Plotting
plotshape(isEveningStar, title = "Evening Star", color = color.red, style = shape.arrowdown, text = "Evening\nStar", textcolor = color.red, size = size.normal, location = location.abovebar)
plotshape(isMorningStar, title = "Morning Star", color = color.lime, style = shape.arrowup, text = "Morning\nStar", textcolor = color.lime, size = size.normal, location = location.belowbar)
plotshape(isShootingStar, title= "Shooting Star", color=color.red, style=shape.arrowdown, textcolor = color.red, size = size.normal, text="Shooting\nStar")
plotshape(isHammer, title= "Hammer", location=location.belowbar, color=color.lime, style=shape.arrowup, textcolor = color.lime, size = size.normal, text="H")
plotshape(isGravestone, title= "Gravestone", location=location.belowbar, color=color.lime, style=shape.arrowup, textcolor = color.lime, size = size.normal, text="G")