The simple moving average: each day's value is the mean of the
last days closes, that day included, so the first days - 1 days have
none.
Value
A numeric vector as long as close, NA for the first
days - 1 days, and all NA when there are fewer than days closes,
as for an index younger than the average.
Examples
moving_average(c(1, 2, 3, 4, 5), days = 3)
#> [1] NA NA 2 3 4