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.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
//@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)