// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © julzen2

//@version=5
indicator("DVI_ValueChart", overlay=false)

var float dvi = na
midpoint = (high + low + high[1] + low[1] + high[2] + low[2] + high[3] + low[3] + high[4] + low[4]) / 10

dvu = (volume * (high - low) + volume[1] * (high[1] - low[1]) + volume[2] * (high[2] - low[2]) + volume[3] * (high[3] - low[3]) + volume[4] * (high[4] - low[4])) / 5 * 0.02

dv = volume * ((close - midpoint) / midpoint)
dv := dvu != 0 ? dv / dvu : 0

dvi := na(dvi[1]) ? dv : dvi[1] + dv

plot(dvi, title="DVI_ValueChart", color=color.aqua, linewidth=1)

