Moving averages appear to be plotting from right to left on my timeseries. Here is my code:
library(Quandl)
library(ggplot2)
# Get Historical Futures Prices: Crude Oil Futures from Quandl. Contract Code is CL
CME_CL_Data <- Quandl('CHRIS/CME_CL1', start_date = '2021-01-01')
# Plot the OHLC Barchart of the Crude Oil Futures Historical Prices
ggplot(CME_CL_Data, aes(x = Date, y = Last)) +
geom_barchart(aes(open = Open, high = High, low = Low, close = Last)) +
xlab('') + ylab('Daily Prices') +
ggtitle('Future Daily Prices: WTI Crude') +
geom_ma(ma_fun = SMA, n=20, linetype = 1, size = .75) +
geom_ma(ma_fun = SMA, n=50, color = 'red', size = 1.25) +
theme_light()
And here is the output chart: Chart of CL with Moving Averages
I can't seem to pinpoint what I am doing to cause this.