如何在chart_Series add_MACD中更改macd /信号线的颜色

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

我希望仅更改chart_Series中add_MACD图表中MACD线或信号线的颜色。

我的示例代码是:

getSymbols("GSPC")
myChart_Theme <- chart_theme()

chart_Series(GSPC,
         subset = "2017/",
         type = "candlesticks",
         theme = myChart_Theme,
         TA = 'add_MACD(histogram = FALSE)'
         )

我都尝试过:

myChart_Theme <- chart_ theme
myChart_Theme$macd$macd <- "blue"

以及

TA = 'add_MACD(histogram = FALSE, col = c("blue","blue","blue","blue"))'

但是似乎都不起作用,并且两条线始终都是黑色的。

有人可以建议如何开始工作吗?谢谢

r quantmod
1个回答
0
投票

这将起作用:

getSymbols("SPY")
cs <- chart_Series(SPY, subset="2019/", type="candlesticks", TA='add_MACD(histogram=FALSE)')
cs$Env$theme$macd$macd = 'blue';
plot(cs)
© www.soinside.com 2019 - 2024. All rights reserved.