Cumulative Volume Price
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © VanHe1sing

//@version=5
indicator("Cumulative Volume Price")

//Inputs
length  = input.int(20, "Length")
length_ = input.int(2, "Length of Rise")

//Variables
var cumvol = 0.0
var cumprice = 0.0

cumvol   += nz(volume)
cumprice += nz(close)

//Calculations
net = (cumprice * volume) / cumvol
net_  = ta.rising(ta.ema(close, length), length_) ? net : -net

plot(net_, style = plot.style_histogram, color = net_ > 0 ? color.green : color.red)
