Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addVo() and pretty scale #276

Open
jsramseyer opened this issue Sep 19, 2019 · 2 comments
Open

addVo() and pretty scale #276

jsramseyer opened this issue Sep 19, 2019 · 2 comments

Comments

@jsramseyer
Copy link

jsramseyer commented Sep 19, 2019

Description

Chartseries adds (by default) a second volume chart, equivalent to "addVo ()"

The volume chart scale is represented in a friendly way (x thousand, x one hundred thousand, etc.)

When we add the Volume average to this graph, it is plotted without friendly scaling (x unit) and is outside the plot area.

Expected behavior

he expected behavior is to represent "SMA (Vo (VALE3.SA), n = 20)" on the same scale as the variable that created the second graph, in this case "Vo ()".

Minimal, reproducible example

# incorrect behavior of function Vo() in second graph
fim <- Sys.Date()
inicio <- Sys.Date() - 730

getSymbols("VALE3.SA", from= inicio, to = fim)
chartSeries(VALE3.SA, theme = "white", TA='addEMA(n=21); addVo(); addTA(SMA(Vo(VALE3.SA), n=20), on=2)', subset = 'last 6 months')

# correct behavior, add function in second graph, but not Vo() function
chartSeries(VALE3.SA, theme = "white", TA= 'addEMA(n=21,col="red"); addOBV(); addTA(EMA(OBV(Cl(VALE3.SA), Vo(VALE3.SA)), n=10), on =2)', subset = 'last 6 months')


Session Info

[Insert your sessionInfo() output]
@helgasoft
Copy link

You may get the desired result with the newer charting functions. Try this:

d <- na.omit(getSymbols("VALE3.SA", from=Sys.Date()-300, to=Sys.Date(), auto.assign=FALSE))
rm(g)  # remove graphics chob in case it exists already
g <- chart_Series(d, TA='add_EMA(n=21, on=1); add_Vo()', name='vale3.sa')
g <- add_TA(SMA(Vo(d), n=20), col='blue', on=2)
plot(g)

@joshuaulrich
Copy link
Owner

I agree that this is a bug in chartSeries() and/or addTA(), but I'm not sure it's worth the effort to try and fix. Especially when chart_Series() works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants