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.
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
//@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)