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.
Set the volume period to non-zero if you want to use a generalized double EMA instead of plain.
The "ratio" option will show the size of the current volume compared to the average volume as computed for the specified time period; say hello to fat tails and goodby to "standard" and "normal" and "average". With the "together" option, it compares the current volume to the both sides together (buy+sell), otherwise it compares it to just its respective side.
Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?
//@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.
//
// Set the volume period to non-zero if you want to use a generalized double EMA instead of plain.
//
// The ratio option will show the size of the current volume compared to the volume in the specified time period (expect to see something VERY non-Gaussian!)
// With "together" it compares it to the full volume, otherwise it compares it to just its own (buy or sell) side.

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


buy_  = dema(close > open ? volume*open : 0, p)
sell_ = dema(close < open ? volume*open : 0, p)

ra = input(false, "Ratio")

bs = bs0 or not ra and neg == -1

buy  = ra ? (close > open ? volume / ( buy_[1] + (bs ? sell_[1] : 0))  : 0) : buy_
sell = ra ? (close < open ? volume / (sell_[1] + (bs ?  buy_[1] : 0))  : 0) : sell_

bsv = bs ? nz(buy) + (ra ? 1 : neg) * nz(sell) : buy

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