Buy_Sell_Vol_with_50EMA
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © astralytics
//@version=4

// Sets the variable for the default integer to 50 for the EMA (The lower the 
// input integer, the tighter the ema() band becomes in relation to volume).
volPeriod = input(50, "Period")
// Variable to pass the volume and volPeriod into the ema() function params.
vEma = ema(volume, volPeriod)
study("BS",format=format.volume, precision=0)
// Buy volume bar formula.
bV = iff((high==low), 0, volume*(close-low)/(high-low))
// Sell volume bar formula.
sV = iff((high==low), 0, volume*(high-close)/(high-low))
// Plots the seller's volume.
plot(volume, style=plot.style_columns, color=color.red, title="SellVol") 
// Plots the buyer's volume.
plot(bV, style=plot.style_columns, color=color.teal, title="BuyVol")
// Plots the moving average.
plot(vEma,style=plot.style_line, color=color.white, title="VolPeriod")