[KVA]Donchian 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]Donchian Channel Percentage", shorttitle="DC%", overlay=false)

// User-defined input for the lookback period of the Donchian Channel
length = input(20, title="Length")

// Calculating the Donchian Channels
upper = ta.highest(high, length)
lower = ta.lowest(low, length)

// Calculate Donchian Channel Percentage
dc_percent = (close - lower) / (upper - lower) * 100

// Plotting the Donchian Channel Percentage
plot(dc_percent, title="DC%", color=color.blue, linewidth=2)

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

