Reputation: 1
Hi i have looked endlessly and cannot figure out how to achieve this in pine. Would anyone be willing to help me with this? i want to ID the highest volume bar in say a session, or day, week, then launch a continuous vwap from that candle. whether it be a 1min candle or daily. can point me in the right direction or possibly what to start with as far as pine goes?
Upvotes: 0
Views: 1074
Reputation: 3833
//@version=4
study("Highest Volume Interval VWAP", overlay = true)
interval = input("D", title = "Interval")
src = input(hlc3, title = "source")
new_interval = change(time(interval)) != 0
var float highest_volume = na
var float pvsum = na
var float vsum = na
bool signal_new_vwap = false
if new_interval
highest_volume := volume
pvsum := volume * src
vsum := volume
signal_new_vwap := true
else if volume > highest_volume
highest_volume := volume
pvsum := volume * src
vsum := volume
signal_new_vwap := true
else
pvsum := pvsum + volume * src
vsum := vsum + volume
hvi_vwap = pvsum / vsum
plot(hvi_vwap)
plotshape(signal_new_vwap, location = location.belowbar, style = shape.triangleup, color = color.blue, size = size.small)
bgcolor(new_interval ? color.fuchsia : na)
Upvotes: 0