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

superSmoother function #6

Closed
npatwa opened this issue Feb 24, 2016 · 2 comments
Closed

superSmoother function #6

npatwa opened this issue Feb 24, 2016 · 2 comments

Comments

@npatwa
Copy link

npatwa commented Feb 24, 2016

Hi Ilya,

First up, many thanks for making available the Dr. Ehler indicators in R. I am slowly exploring them and came across the superSmoother function.

I believe the line

filt <- c1*(x+lag(x))/2

should actually be

filt <- c1*(x+lag(x, k=-1))/2 to match Dr. Ehlers equation given in the book 'Cycle Analytics for Traders'.

Can you please check?

Thanks,

Najmuddin

@braverock
Copy link
Collaborator

lag(x, k=-1) would introduce look-ahead bias.

Is that what you want?

lag.xts lags a timeseries in the correct direction, and defaults to 1, so it will always lag 'back' from the current observation. lag in base R lags the wrong direction (for time series).

@npatwa
Copy link
Author

npatwa commented Feb 24, 2016

Hello,

Sorry my bad.

While the supersmoother works perfectly well for xts type objects, it doesn't have the leading NAs for zoo type objects. hence I felt there was somehting wrong with the code.

Thanks,

Najmuddin

@npatwa npatwa closed this as completed Feb 24, 2016
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