Visualizing the trend of the stock by using moving average method

visMovingAverage(data, window, name)

Arguments

data

xts a time series object

window

A numeric vector of the size of the window (number of days) used in moving average calculation

name

a character vector of the name of the column to be used in moving average calculation

Value

A ggplot line plot of specific stock's historical prices and moving average prices

Examples

quantmod::getSymbols("AAPL")
#> [1] "AAPL"
visMA_AAPL <- visMovingAverage(AAPL, 300, 'AAPL.Close')