traileriana

Volume (D)EMA

A simple yet configurable indicator that shows recent traffic volumes.
The time period is specified as weeks/days/hours/minutes, not as bars.
For using the generalized double EMA, set the velocity to something other than zero.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//@version=2

// A simple yet configurable indicator that shows recent traffic volumes.
// The time period is specified as weeks/days/hours/minutes, not as bars.

study("Volume (D)EMA")

pw = input(0.0,"Weeks")
pd = input(0.0,"Days")
ph = input(8.0,"Hours")
pm = input(0,"Minutes", minval=5, step=5)

iv = period == 'M' ? 30*24*60 : period == 'W' ? 7*24*60 : period == 'D' ? 24*60 : interval // current interval in minutes
p = max(1,round(7*24*60*pw + 24*60*pd + 60*ph +pm) / iv)

v = input(0.0, "DEMA Velocity", step=0.1)

gdema(x, p, v) =>
    e = ema(x, p)
    (1+v) * e - v * ema(e, p)

dema(x, p) => gdema(x, p, v)

bs0 = input(false, "Together")
neg = input(false, "Difference") ? -1 : 1
bs = bs0 or neg == -1

buy  = dema(close > open ? volume*open : 0, p)
sell = dema(close < open ? volume*open : 0, p)

bsv = buy + neg * sell

plot(bs ? bsv : buy, style=columns, color = bsv < 0 ? red : navy)
plot(bs ? na : -sell, style=columns, color = red)