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

TTR SMA feature request parameter for NA at the end #40

Closed
siims-biz opened this issue Jan 29, 2017 · 1 comment
Closed

TTR SMA feature request parameter for NA at the end #40

siims-biz opened this issue Jan 29, 2017 · 1 comment

Comments

@siims-biz
Copy link

In the documentation I did not find a parameter to move the NA to the end.
Is there one around?

> kurs <- c(1,2,3,4,5,6)
> sma3<-SMA(kurs,n=3)
> sma3
[1] NA NA  2  3  4  5
> 

Default output NA NA 2 3 4 5
With additional parameter the output changes to 2 3 4 5 NA NA

@joshuaulrich
Copy link
Owner

You didn't find such a parameter in the documentation because one doesn't exist. For technical indicators, it is generally a very bad idea to align the output to anything other than the last observation in the period. Anything else has a very real potential to create look-ahead bias.

If you really want to do this, you should use zoo::rollmean.

R> zoo::rollmean(kurs, 3, fill = NA, align = "left")
[1]  2  3  4  5 NA NA

I'm closing this because I'm not comfortable adding it as a feature, and alternatives alrady exist.

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

2 participants