dygraphs icon indicating copy to clipboard operation
dygraphs copied to clipboard

New Features

Open vikram-rawat opened this issue 8 years ago • 4 comments

Can you add a feature to add bartype chart under the dygraph plot. Because sometime we need to View OHLC with Volumes. and Can we Add one graph under another graph.

Please add these features

vikram-rawat avatar Aug 03 '17 08:08 vikram-rawat

After PR #172 , You should be able plot OHLC through dyCandlestickGroup, and add the volume as a separate plotter on the same plot on the y2 axis - probably with dyBarSeries based on your description. PR #165, though merged, has a bug that needs to be addressed by #172. If you don't want to wait for the PR to be merged here, you temporarily grab my fork: https://github.com/klaukh/dygraphs/

Purely adding a second graph under the first can be done in RStudio Viewer using RMarkdown... see https://github.com/rstudio/dygraphs/issues/59 on the RStudio GH page

klaukh avatar Aug 05 '17 13:08 klaukh

Thank you very much for replying Timeseries is mostly used in economics. Infact it started with Economics. R still doesn't have a perfect timeseries library so thanks a lot for creating this one. I really appreciate the effort.

But in order for it to be perfect. We would still Need.

  1. Time Series Group Buttons on the top
  2. Regression and Other lines Through the ploting calculation
  3. Adding Barcharts.
  4. Should be compatible with crosstalk

I mean technically we should be able to reproduce this code with the least effort. it's an example from highcharter.

When you deal with daily ticks of 5 years this feature comes in Handy. Whereas this code ---

data(sample_matrix) sample_matrix %>% dygraph() %>% dyCandlestick(compress=TRUE) %>% dyRangeSelector()

Only calculates it on the first screen not after you zoom in...

Please run the below code and click on the buttons above which recalculate the Boxes based on a different timeframe.

================================

library(highcharter) SPY <- getSymbols("SPY", from = Sys.Date() - lubridate::years(1), auto.assign = FALSE) SPY <- adjustOHLC(SPY)

SPY.SMA.10 <- SMA(Cl(SPY), n = 5) SPY.SMA.200 <- SMA(Cl(SPY), n = 100) SPY.RSI.14 <- RSI(Cl(SPY)) SPY.RSI.SellLevel <- xts(rep(70, NROW(SPY)), index(SPY)) SPY.RSI.BuyLevel <- xts(rep(30, NROW(SPY)), index(SPY)) highchart(type = "stock") %>% hc_yAxis_multiples( create_yaxis(3, height = c(2, 1, 1), turnopposite = TRUE) ) %>% hc_add_series(SPY, yAxis = 0, name = "SPY") %>% hc_add_series(SPY.SMA.10, yAxis = 0, name = "Fast MA") %>% hc_add_series(SPY.SMA.200, yAxis = 0, name = "Slow MA") %>% hc_add_series(SPY$SPY.Volume, color = "gray", yAxis = 1, name = "Volume", type = "column") %>% hc_add_series(SPY.RSI.14, yAxis = 2, name = "Osciallator", color = hex_to_rgba("green", 0.7)) %>% hc_add_series(SPY.RSI.SellLevel, color = hex_to_rgba("red", 0.7), yAxis = 2, name = "Sell level") %>% hc_add_series(SPY.RSI.BuyLevel, color = hex_to_rgba("blue", 0.7), yAxis = 2, name = "Buy level")

================================

================================

I understand I am asking for a lot. I would understand if It's too much to ask. But This is one of the primary reason why R is not used in Finance as much SAS does. And KUDOS to your effort. But do reply please

================================

vikram-rawat avatar Aug 07 '17 14:08 vikram-rawat

I tried dyCandlestickGroup()

but It's not properly documented I am unable to figure out how to make them automatically group on zooming.

sample_matrix %>% dygraph() %>% dyCandlestick(compress=TRUE) %>% dyCandlestickGroup(c('Open', 'High', 'Low', 'Close')) %>% dyRangeSelector()

Let me know if I am doing anything wrong

vikram-rawat avatar Aug 09 '17 14:08 vikram-rawat

The compression option was not included for dyCandlestickGroup since it would have been incorrect to assume an arbitrary aggregation function to perform on all the remaining series, since dyCandlestickGroup keeps and plots the series not included in the candlestick plot.

It would be perfect to have someone from the community with this type of need to do a new plotter that addresses this. I can see this accomplished through a combination of the candlestickgroup, candlestick chart, and barseries plotters and R wrapper functions. I think most of the code is already there... just needs to be combined and collated in a way tailored to this requirement.

klaukh avatar Aug 12 '17 20:08 klaukh