Quantmod addMACD()删除线图

问题描述 投票:0回答:1

我目前正在使用Quantmod来可视化股票数据的技术分析。当我遇到添加MACD图的addMACD()函数时,它工作正常,除非我需要仅显示直方图而不是线图。

addMACD(fast = display$macdFast, slow = display$macdSlow, signal = display$macdSignal, histogram = TRUE)

阅读完文档后,我无法找到一种方法来删除MACD图的线图。可以在保留MACD直方图的同时删除线图吗?

enter image description here

r charts shiny quantmod technical-indicator
1个回答
0
投票

我似乎总是在使用quantmod创建复杂的newTA对象时遇到问题,但here是一个SO示例。我发现使用rtsplot更容易。这是xts对象的绘图包,但基于基础图。

由于macd直方图只是macd和macd信号之间的差异,你可以创建自己的直方图值:

library(quantmod)
goog <- getSymbols("GOOGL", from = "2019-01-01", auto.assign = F)
goog_macd <- MACD(goog$GOOGL.Close)
goog_macd_his <- goog_macd$macd - goog_macd$signal


library(rtsplot)
layout(c(1,1,1,2))
rtsplot(goog, type = "candle")
rtsplot(goog_macd_his , type = "h", lwd = 2)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.