I’m trying to draw VWAP line at a certain period of time every day in pinescript on Tradingview, but script draws it only at current day and doesn’t in the past.
Script i use.
Could you help me to change it pls?
indicator("VWAP (10:00 - 15:30)", overlay=true)
t1 = time(timeframe.period, "1000:123456")
t2 = time(timeframe.period, "1530:123456")
calc_vwap_in_session(start_hour, start_minute, end_hour, end_minute) =>
var float cum_price_volume = na
var float cum_volume = na
if (na(cum_price_volume))
cum_price_volume := 0.0
cum_volume := 0.0
start_time = timestamp("GMT+3", year(timenow), month(timenow), dayofmonth(timenow), start_hour, start_minute)
end_time = timestamp("GMT+3", year(timenow), month(timenow), dayofmonth(timenow), end_hour, end_minute)
if (time >= start_time and time <= end_time)
cum_price_volume += (high + low + close) / 3 * volume
cum_volume += volume
vwap = cum_price_volume / cum_volume
vwap
plot(calc_vwap_in_session(10, 0, 15, 30), color=color.blue, linewidth=2, title="VWAP (10:00 - 15:30)")````
New contributor
Владимир Смотров is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.