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

Issue when using next() #1184

Open
ed5555 opened this issue Nov 26, 2024 · 1 comment
Open

Issue when using next() #1184

ed5555 opened this issue Nov 26, 2024 · 1 comment

Comments

@ed5555
Copy link

ed5555 commented Nov 26, 2024

When trying to run a simple 200 MA strategy, I want make a purchase at the onset of the data. However, the next function iterates only from the onset of the data+200 days.

Is there a way to do this?

Thank you

@sachaRfd
Copy link

sachaRfd commented Dec 8, 2024

When implementing a strategy with 200 MA, you need to account for the initial calculation period. For example with a 200-day MA, you need the data of the previous 200 days before you can generate a valid MA value. During the calculation period, the MA will be NaN - so no signal. This means the strategy will only work from 200 days onwards.

Quick fixes in your case would be to either:

  1. Collect more historical data to your desired start-date.
  2. Pick a later start date where you already have the previous 200 data points.

Hope that makes sense.

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