Skip weekends in walk-forward testing


When I do walk-forward testing with one day increment, I find that weekends are being tested too. As shown in above pic, 8/8/2020 (Sat) is being calculated/tested, and show as blank. 8/9/2020 (Sun) is also being calculated/tested, and has result (why?).

Symbol is NQ futures using IQFeed datasource, interval is 1 min. I have added the following code to AFL but doesn't seem to work.

Exclude = (DayOfWeek() == 6) OR (DayOfWeek() == 0); // 6 = Sat, 0 = Sun

Is the code correct? If so, what else should I do to skip weekends?

You don't need to code anything. Just use:

View->Filtering->Filter weekends

That's all.

@Tomasz I have weekends filtered (see below), and it's still showing up


In thinking about this more, perhaps a better solution would be to skip market close days (weekends and holidays).

Reason being when IS is Friday (8/7, 8/14, etc), OOS is Sat. Ideally OOS should be next market open day (Monday), not next calendar day, as OOS on a market close day skews the result.

I've thought about using TimeFrameCompress function to identify current date. But not sure about how to pass it to walk-forward testing to skip unwanted (market close) days.

If you are filtering weekends that's good.
It means that during weekends you will get ZERO trades and "empty" result.
And that is what you see on your screenshot.
Such backtest (no data) take NO TIME at all.

BTW: In-sample and Out-of-sample of ONE DAY make no sense. You are over-fitting. Even if you are using tick data, the reasonable walk-forward IS/ OOS period is at least one week.

1 Like

What I'm doing is an experiment on intraday strategy with high sensitivity.

My intention is to use previous day's optimal setting (IS) and apply that to next day (OOS). So Monday will use Friday's optimal setting, Tuesday will use Monday's optimal setting, Wednesday will use Tuesday's optimal setting... etc, and see in long run how that will work out.

What I am observing is that test breaks when IS day or OOS day has no data (market not open -- weekends or holidays). Is there a way to detect that using AFL and skip to next available market day?

Something along the line of

... if no daily bar for today, use next daily bar as current bar ...

An possible alternative way to deal with this could be in addition to "filter weekends", we also have the ability to "filter market closed days" -- exclude days that has no daily bar from testing completely. So walk forward tests using "days" as steps are done based on daily bar availability instead of calendar days. E.g. 3 days means "Thursday, Friday, Monday," not "Thursday, Friday, Saturday."

I've also observed Sundays are being tested/calculated despite "filter weekends" is enabled. I'll create another post on that.

In any case, Happy New Year and thanks for the great software :slight_smile: