Your interactive trading laboratory!
 • 
9 users online

Seed Data for Long Indicators
This is a Feature Request with 4 votes

Problem: The 200-day moving average takes 200 days to produce a valid result to use in a model. If I I start a simulation in Jan 2000, the model won't be able to trade until approx. Nov 2000 - that's nearly a year without results, which affects the model's annualized metrics.

Solution: Provide a way to create indicator using seed data so that indicators are valid on the first bar of the Backtest. In the example above, if I were able to load all the BarHistory available for a symbol, create an indicator like SMA(200) and then synchronize it to the model's Data Range, trading would be possible on bar index 0 (or 1).

Ideally, this would occur 'magically' in the background. A BarHistory called from an IndicatorBase in Initialize() would load all the BarHistory, create and then synchronize the indicator.

Attachment

Cancel

Responses

In the meantime, of course, you can use StartIndex = 199 (or 200) in the Initialize function (https://www.quantacula.com/Help/OpenHelp/csharp/20) to set the actual start date of the backtest so that the 200 days are accounted for manually. It won't give you 200 extra days of data to use, but it will properly synchronize the start of the backtest with the benchmark.

In the meantime, of course, you can use StartIndex = 199 (or 200) in the Initialize function (https://www.quantacula.com/Help/OpenHelp/csharp/20) to set the actual start date of the backtest so that the 200 days are accounted for manually. It won't give you 200 extra days of data to use, but it will properly synchronize the start of the backtest with the benchmark.

Indeed, pondering this, I feel the best way to handle it might be to give even more power to StartIndex. Rather than building some complicated seed data mechanism, maybe the resulting equity curve can be pruned to StartIndex prior to calculating its metrics. I think this would achieve the desired result in a much simpler way.

Indeed, pondering this, I feel the best way to handle it might be to give even more power to StartIndex. Rather than building some complicated seed data mechanism, maybe the resulting equity curve can be pruned to StartIndex prior to calculating its metrics. I think this would achieve the desired result in a much simpler way.

@bitfool - Right now, StartIndex is just a way to keep Q from unnecessarily processing bars that you know will not be valid for trading. It doesn't (or at least I'm not aware that it does) currently influence calculations for annualized metrics.

@Glitch - I'm not sure I'd be convinced that that would be simpler and without potential undesirable side effects. Doing what it takes to make indicators valid on idx 0 seems pretty simple without messing with anything else.

@bitfool - Right now, StartIndex is just a way to keep Q from unnecessarily processing bars that you know will not be valid for trading. It doesn't (or at least I'm not aware that it does) currently influence calculations for annualized metrics. @Glitch - I'm not sure I'd be convinced that that would be simpler and without potential undesirable side effects. Doing what it takes to make indicators valid on idx 0 seems pretty simple without messing with anything else.

QProfessor - I don't see how making indicators valid on idx 0 is simpler. It means some major changes to how the data is loaded, and potentially an additional data load step that would definitely impact performance. Do you have any insight on how to accomplish this without the complexity and negative performance impact that I'm feeling from the suggestion?

QProfessor - I don't see how making indicators valid on idx 0 is simpler. It means some major changes to how the data is loaded, and potentially an additional data load step that would definitely impact performance. Do you have any insight on how to accomplish this without the complexity and negative performance impact that I'm feeling from the suggestion?

If you want data older than 2000 get it from IQFeed with an Extended Subscription to US Stocks.

If you want data older than 2000 get it from IQFeed with an Extended Subscription to US Stocks.

Pruning the result curves based on StartIndex is working well! Here's a result with a model using one year of lead bar data (252 daily bars). Note the equity curve commences right from the get go, and the metric calculations are not distorted by lead data. The only thing, you'll need to increase your start date to compensate for the StartIndex lead data, but I think this is the cleanest and simplest solution. The only thing left is intelligently setting the StartIndex for Building Block and Rotation models.

Pruning the result curves based on StartIndex is working well! Here's a result with a model using one year of lead bar data (252 daily bars). Note the equity curve commences right from the get go, and the metric calculations are not distorted by lead data. The only thing, you'll need to increase your start date to compensate for the StartIndex lead data, but I think this is the cleanest and simplest solution. The only thing left is intelligently setting the StartIndex for Building Block and Rotation models.

Pruning of the equity curves based on StartIndex is now in Q179!

Pruning of the equity curves based on **StartIndex** is now in Q179!
Forum Tips

Please sign in if you want to participate in our forum.

Our forum uses Markdown syntax to format posts.

To embed code snippets, enclose them in [CODE][/CODE] tags.