Move Up/Down in X days
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheDiscordia

//@version=5
indicator("Move Up/Down in X days")
pmove = input.int(20, title="Percentage Move", minval=1, maxval=300, step=1)
xdays = input.int(5, title="Days", minval=1, maxval=100, step=1)
xvolume = input.int(9, title="Volume (Millions)", minval=1, maxval=300, step=1)
upInputColor = input.color(color.green, "Up Color")
upColor = color.new(color = upInputColor, transp = 20)
downInputColor = input.color(color.red, "Down Color")
downColor = color.new(color = downInputColor, transp = 20)
volumeColor = input.color(color.orange, "Volume Color")

days = xdays
v = close -  close[days]
t = (v / open[days]) * 100
u = (t >= pmove or t < -pmove) ? t : 0

vup = (u > 0) ? 1 : 0
plot(vup, color=upColor, style=plot.style_areabr)

vdown = (u < 0) ? 1 : 0
plot(vdown, color=downColor, style=plot.style_areabr)

volup = volume > (xvolume * 1000000)
volGtYest = volume > volume[1]
vv = close - close[1]
tv = (vv / open[1]) * 100
showVolumeBar = volup and volGtYest and (tv >= 4 or tv <= -4)

vbar = showVolumeBar ? 0.5 : 0
plot(vbar, color=volumeColor, style=plot.style_columns)
