The Golden Candlestick Pattern
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar

//@version=5

indicator("Candlestick Pattern - Golden Pattern", overlay = true)

golden_difference = 2.618 * (high[2] - low[2])

bullish_pattern = low <= open[1] and close[1] > (golden_difference + low[2]) and close[2] > open[2] and close[1] > open[1]
bearish_pattern = high >= open[1] and close[1] < (high[2] - golden_difference)  and close[2] < open[2] and close[1] < open[1]

plotshape(bullish_pattern,  style = shape.triangleup,   color = color.green,  location =  location.belowbar, size = size.small)
plotshape(bearish_pattern,  style = shape.triangledown, color = color.red,    location =  location.abovebar, size = size.small)