I'm trying to figure out how to make the walk forward optimization work properly.
Let's say I have a simple strategy that utilizes a SMA, calculated over a period of 40 bars. When running the strategy on a chart, I'd simply load 40 bars prior to the date I want to start the strategy at and add something like this to my script:
if (CurrentBar < 40) return;
However, how can I make this work in a WFO?
For example: if I want to do a WFO with 7 days optimization and 1 day test periods. The 40 bars required for my SMA amount to about 2 days of data in total. Now I get the situation where the WFO actually skips two days of the 7 in the optimization and more importantly won't even do any trades in the 1 day test period, correct? Because the strategy won't trade before 40 bars have passed, which never happens in the 1 day test period in my example.
I've tried using AddDataSeries() with the barsToLoad overload, but this apparently doesn't work in the Strategy Analyzer. What I need is to ensure that all historical data required for proper calculation of my indicators is present right at the start of each optimization and test period, so that I do not have to skip the first X bars. How can I do this?
I've found some info on BarsRequest, but going that route seems rather cumbersome just to make a WFO work properly.
Any help is appreciated.
Thanks!
Comment