TradingView
stuehmer
12 cze 2019 06:13

Anchored VWAP 

Bitcoin / US Dollar Perpetual Inverse Swap ContractBitMEX

Opis

Anchor vwap to begin at a certain time. Uses hlc3 for vwap calculations.
Komentarze
chris17cars
hi, is there some special inputs needed to get this anchor vwap to work, ohter than the date?
i can not get this script to plot a line on the chart, not sure what im doing wrong.
stuehmer
@chris17cars, hey I've recently noticed that the indicator only works on tickers that trade 24/7. The script works on crypto and forex but not with stocks or futures. Working on a fix for this but might take a few days
varungupta0802
@stuehmer, hi, just wanted to know if there is a fix now for stocks and can you please suggest the fix
stuehmer
@varungupta0802, here is the updated code for working with stocks

//@version=4
study(title = "Anchored VWAP", shorttitle = "AVWAP", overlay = true)

src = input(hlc3)

y = input(2019, minval = 1, maxval = 2099, title = 'Year', confirm = true)
m = input(1, minval = 1, maxval = 12, title = 'Month', confirm = true)
d = input(1, minval = 1, maxval = 31, title = 'Day', confirm = true)
h = input(0, minval = 0, maxval = 23, title = 'Hour', confirm = true)
min = input(0, minval = 0, maxval = 59, title = 'Minute', confirm = true)

t = timestamp(y, m, d, h, min)
start = time >= t and time[1] < t

sumSrc = src * volume
sumVol = volume
sumSrc := start ? sumSrc : sumSrc + sumSrc[1]
sumVol := start ? sumVol : sumVol + sumVol[1]

plot(sumSrc / sumVol, title = "AVWAP")
stinkbug
@stuehmer, Hi why is the line continuous, what if you just wanted to anchor it to a day and go forward?
gbenenyan28145
Does anyone realize that we are just plotting "src" ?
sumSrc = src * volume
sumVol = volume

sumSrc/sumVol ===> src
louie_etoro01
how to use this indicator? right click on the candle then add indicator? cant seem to make it work. thanks
OrcChieftain
I looked for this I even started coding it myself. It seems your solution doesn't work under all circumstances and is not 100% what I wanted, but I think how to finish now. Thanks for keeping the source public.
stuehmer
@greenmask9, See my comment below
Pladizow
Hello,

Nice indicator - thanks for sharing.

Any way to script it to select both the start and stop date?

This would allow us to select specific periods in time, not just all data to present.

Thanks!
Więcej