Pin Candle Detection
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xfuturesgod

//@version=5
indicator("Pin Candle Detection", overlay = true)
fibLevel = input.float(0.55,"Candle Fibonacci Level", minval = 0, maxval = 1)
wickSize = input.float(7, "Wick Length", minval = 1)

greenCandle = close > open
redCandle = open < close

fibCalc = (low - high) * fibLevel + high

// Determine which price source closes or opens highest/lowest
lowestBody  = close < open ? close : open

// Determine if we have a valid pin/hammer candle
validClose = lowestBody >= fibLevel
wickFilter = lowestBody - low >= 7
validPin = validClose and wickFilter

plotchar(validPin, title = "Pin Candle", char = "P", color = color.purple)
alertcondition(validPin, "Pin Candle Setup", "Pin Candle")