【问题标题】:Y-scale of addRSI graph [Quantmod]addRSI 图的 Y 尺度 [Quantmod]
【发布时间】:2019-08-10 20:24:32
【问题描述】:

使用 Quantmod,我可以使用 addRSI() 绘制股票数据的 RSI,但该图的 y 比例尺不可调整,我需要的是能够像任何正常的 RSI 图一样将 y 比例尺调整为 0 - 100可以。

addRSI(n = 14) %>% print

但是,在使用以下逻辑绘制 RSI 后,弹出错误消息,我不知道如何设置 RSI() 的价格参数,因为文档没有指定该参数的确切含义.

print(addTA(RSI(price = 100, n = 14), yrange = c(0,100)))

是否有任何解决方案可以绘制 y 尺度为 0 - 100 的 RSI?

【问题讨论】:

    标签: r plot charts shiny quantmod


    【解决方案1】:

    您可以使用addTAyrange 选项,而不是使用addRSI(由于某种原因它具有基于值的固定范围)。

    使用 quantmod:

    library(quantmod)
    
    goog <- getSymbols("GOOGL", from = "2019-01-01", auto.assign = F)
    rsi <- RSI(goog$GOOGL.Close)
    
    chartSeries(goog, TA = NULL)
    addTA(rsi, yrange = c(0, 100))
    

    或者 quantmod 的 chart_Series 函数。这会在 0-100 范围内添加 rsi,但不会仅显示 70 和 30 处的标签。

    chart_Series(goog)
    add_RSI()
    

    使用 rtsplot(直接来自帮助的代码):以 20 为步长显示从 0 到 100 的 rsi 范围,并突出显示 0-30 和 70-100 波段。

    library(rtsplot)
    layout(c(1,1,1,2))
    rtsplot(goog, type = "candle")
    rtsplot(rsi, type = 'l', ylim=c(0,100),
            y.highlight = c(c(0,30), c(70,100)),
            y.highlight.col = grDevices::adjustcolor(c('green','red'), 50/255)
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-04
      • 1970-01-01
      • 2013-03-14
      • 1970-01-01
      • 2018-12-10
      • 2016-09-24
      • 1970-01-01
      • 2023-04-08
      相关资源
      最近更新 更多