OPEN-SOURCE SCRIPT

Average Volume

66
//version=5
indicator("Average Daily Volume", overlay=false)

// --- Inputs
lookback = input.int(20, "Lookback Period (Days)", minval=1)

// --- Convert chart timeframe to daily volume
// If you’re on intraday, TradingView aggregates intraday bars belonging to a single day
is_new_day = ta.change(time("D")) != 0
daily_volume = ta.valuewhen(is_new_day, volume, 0)

// --- Average daily volume
avg_daily_volume = ta.sma(daily_volume, lookback)

// --- Plot
plot(avg_daily_volume, title="Avg Daily Volume", color=color.new(color.blue, 0))

免責聲明

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.