[KVA]Keltner Channel Percentage
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Kamvia

//@version=5
indicator("[KVA]Keltner Channel Percentage", shorttitle="KC%", overlay=false)

// User-defined input for the length and the source of the Keltner Channel
length = input(20, title="Length")
src = close
mult = input(2.0, title="Multiplier")

// Calculating the Keltner Channels
basis = ta.sma(src, length)
upper = basis + mult * ta.atr(length)
lower = basis - mult * ta.atr(length)

// Calculate Keltner Channel Percentage
kc_percent = 100 * (src - lower) / (upper - lower)

// Plotting the Keltner Channel Percentage
plot(kc_percent, title="KC%", color=color.blue, linewidth=2)

hline(0, "Lower Bound", color=color.red)
hline(100, "Upper Bound", color=color.green)

