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

//@version=4
study("MyBalance", overlay=false)
period=input(title="Period", type=input.integer, defval=10)
vbd = input(title="Show Volume Bars Back", type=input.integer, defval=3, tooltip="Plot volume histograms back 0=all")
totVol = sum(volume,period)
upVol = close>open ? sum(volume,period) : na
dnVol = close<open ? sum(volume,period) : na
difVol = upVol-dnVol
pVol = (difVol/totVol)*100
plot(upVol/period)
plot(dnVol/period,color=color.red)

plot(volume, show_last=vbd, color=color.yellow, style=plot.style_histogram)
//plot(difVol)