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.
סקריפט קוד פתוח

ברוח 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.
//
// 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)