Search code examples
rplotfinanceinteractive

R Interactive Financial/Asset Candle Chart with Indicator


I am looking for an alternative way to display an Interactive candle charts (if any exists), that looks like this

enter image description here

Above is sample static hourly candle charts with its indicator, because it is static, it is less informative, no hover information included, I generate this chart using quantmod packages, with this simple snippets:

asset1%>%chartSeries(TA=\"addCCI();addRSI();addMFI();\")

Thankyou for any kind of leads!


Solution

  • You could use plotly:

    library(quantmod)
    library(dplyr)
    library(plotly)
    
    AAPL <- getSymbols("AAPL", src='yahoo', auto.assign = FALSE) %>% tail(60)
    
    df <- data.frame(Date=index(AAPL),coredata(AAPL))
    
    fig <- df %>% plot_ly(x = ~Date, type="candlestick",
                          open = ~AAPL.Open, close = ~AAPL.Close,
                          high = ~AAPL.High, low = ~AAPL.Low) 
    
    fig %>% layout(title = "Basic Candlestick Chart")
    

    Created on 2022-05-17 by the reprex package (v2.0.1)

    Screenshot of output:

    example of plot

    See more examples here.