如何在chart_Series add_MACD中更改macd / signal行的颜色

时间:2017-04-11 19:24:29

标签: r quantmod

我希望只更改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"))'

然而,似乎都不起作用,两条线总是黑色。

有谁能建议如何上班?感谢

1 个答案:

答案 0 :(得分:0)

这将起作用:

getSymbols("SPY")
cs <- chart_Series(SPY, subset="2019/", type="candlesticks", TA='add_MACD(histogram=FALSE)')
cs$Env$theme$macd$macd = 'blue';
plot(cs)