Nth Root
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OztheWoz

//@version=5
indicator('Nth Root')

nroot(nsrc, nlen) =>
    num = nsrc
    sqrt = math.pow(num, 1 / nlen)
    sqrt
    
    
    
nlen = input(4, "Root Length")
nopen = nroot(open, nlen)
nhigh = nroot(high, nlen)
nlow  = nroot(low, nlen)
nclose = nroot(close, nlen)
cndclr = (nclose > nopen) ? color.green : color.red
cndbord = (nclose > nopen) ? color.green : color.red

plotcandle(nopen, nhigh, nlow, nclose, color=cndclr, bordercolor=cndbord, wickcolor=color.gray)
