Wick Percentages
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BOTrades

//@version=5
indicator("Wick Percentages", overlay = true)

// Global variable
var position = "Buy"

target = input(50, "Only Show Wick % Greater than")

// Define variables to calculate percentages of the upper wick and the lower wick
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low

// Calculate percentages of the upper wick and the lower wick
upperWickPercentage = (upperWick / (high - low)) * 100
lowerWickPercentage = (lowerWick / (high - low)) * 100

// ROund values down to remove decimal
upperWickPercentage1 = math.floor(upperWickPercentage)
lowerWickPercentage1 = math.floor(lowerWickPercentage)
 

// Print percent of wick ​​above and below each candle
if (upperWickPercentage1 > target or  lowerWickPercentage1 > target)
    if (upperWickPercentage1 > lowerWickPercentage1)
        if (position != "Sell")
            label.new(bar_index, high, str.tostring(upperWickPercentage1)+"%", color = color.red, yloc = yloc.abovebar, textcolor = color.white, style=label.style_arrowdown)
            position := "Sell"
    else 
        if (position != "Buy")
            label.new(bar_index, low, str.tostring(lowerWickPercentage1)+"%", color = color.green, yloc = yloc.belowbar, textcolor = color.white, style=label.style_arrowup)
            position := "Buy"
