Drowdown Market
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tmr0

//@version=5
indicator("tDDM", overlay=true)
perc1 = input.float(0.25, step=.05)
perc2 = input.float(0.5, step=.05)
perc3 = input.float(0.75, step=.05)

max = .0
max := max[1] > high ? max[1] : high

chdd1 = max * (1 - perc1)
chdd2 = max * (1 - perc2)
chdd3 = max * (1 - perc3)

ch0 = plot(high, display=display.none)
ch1 = plot(chdd1, display=display.none)
ch2 = plot(chdd2, display=display.none)
ch3 = plot(chdd3, display=display.none)


fill(ch0, ch1, color=high>chdd1?#00000000:color.red, transp=90)
fill(ch0, ch2, color=high>chdd2?#00000000:color.red, transp=90)
fill(ch0, ch3, color=high>chdd3?#00000000:color.red, transp=90)
