ITMScript
Chart drawdown from the running peak
Chart how far the close sits below its highest value so far, with the worst drop and a warning tint.
Chart how far the close sits below the highest close so far.
//@itmscript 2
study("Drawdown", overlay=false)
warn = input.float(10, "Warning depth, percent", min=1, max=90)
[depth, worst, duration] = ta.drawdown(close)
plot(depth * 100, "Drawdown", color=color.red, width=1, style=area)
plot(worst * 100, "Worst so far", color=color.gray, width=1, style=stepline)
hline(0, "Peak", color=color.gray, style=solid)
bgcolor(depth * 100 < -warn ? color.new(color.red, 90) : na)What you see
A red area in its own pane shows the drawdown in percent. It is 0 on a bar that sets a new peak and negative on every other bar. A grey stepped line shows the worst drawdown so far. A red tint runs behind the bars where the drawdown is deeper than the warning depth.
The peak is the highest close since the first bar loaded. It is not a rolling window, so loading more history can change it.
Change these inputs
- Warning depth, percent. The drawdown at which the tint begins, from 1 to 90 percent.