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.
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?
//@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)