在我的时间序列上,移动平均线似乎是从右到左绘制的。这是我的代码:
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()
这是输出图表:带有移动平均线的 CL 图表
我似乎无法确定我正在做什么来导致这种情况。