< All Topics

Specifying Walkforward In/Out Periods

Specifying Walkforward In/Out Periods

A walkforward has two important time periods associated with it — the in-sample period and out-of-sample period.  Another way of thinking of these periods are as a lookback period (in-sample) and step forward period (out-of-sample).  In this regard, a walkforward is a simulation of what would have happened at each “step forward” point when you optimize the strategy (using the lookback period) and then choose a new set of parameters to trade at that “step forward” point-in-time until you reach the next “step forward” time.

Each period has a period type and a period unit.

Period Types

Calendar Dates — can be used for either lookback (in-sample) or step-forward (out-of-sample periods)

Calendar dates can be specified using any of the following periods:

      • Days
      • Weeks
      • Months
      • Years

Calendar based period types provide a flexible and consistent means to define your lookback periods or step-forward periods. They remain fixed and will not change when the data changes due to data corrections.  If you specify 1 month, for example, for your lookback period, MultiWalk will determine the exact date 1 month ago.  If the current date is March 5, 2023, then 1 month ago would be February 5, 2023.  Calendar units are based solely on the calendar, not number of days in those calendar units.

Important:  While calendar based dates provide better date consistency for the walkforward process, they can still be effected by data changes which may alter the walkforward results.  If, for example, price data was corrected or added that effected the trades and resulting equity curve, the outcome of the walkforward process can change if a different iteration is now considered “best” rather than the original iteration chosen during the previous (before data changes) walkforward.  However, extensive testing has shown that the use of calendar days is still prone to fewer changes in net profit equity changes as opposed to using trading days.

Trading Days — can be used for either lookback (in-sample) or step-forward (out-of-sample periods)

Trading days refer to days that the market is open. Weekends and holidays will not be included.  We use an estimate to approximate one year’s worth of data, where 252 trading days are approximately 365 calendar days.  This is derived as follows:

1 year trading days = 365 – 104 calendar days for weekends (52 * 2) – 9 calendar days for US federal holidays = 252 trading days

However, trading days are based on the days that are present within the data. They are not determined from an external calendar based source, but rather the dates found in the symbol data itself. This makes them prone to these issues:

Data corrections

When dates are added or subtracted due to symbol data corrections, the trading day range will change and effect the outcome of the new walkforward simulation.  Click here for an example of the ramifications of this behavior.

Intraday data that includes Sunday open

252 trading days assume 52 weekends that include both Saturday and Sunday.  This works fine for daily bars where the Sunday open is folded into Monday’s bar. However, intraday strategies that use smaller bars (such as 120, 60, etc. minute bars) will often include Sunday in the daily, periodic data.  You’ll see this behavior when you look at TradeStation’s periodic daily chart or MultiWalk’s periodic walkforward chart.  When this happens, 252 tradings will no longer approximate a year, but rather ~10 months.  When Sundays are included, a more appropriate value to use is 304 trading days (252 + 52 Sundays).

Changes in holidays

Holidays may not always fall on weekdays.  They have also changed through the years, so now there are actually 11 federal holidays.

Using calendar based time periods avoids these issue and provide better consistency for future re-optimizations.

Trade Count — can only be used for lookback (in-sample periods).  You will receive an error if used for step-forward (out-of-sample periods).

Trade count refers the number of trades in the period.  This brings in a level of statistical significance to the walkforward process. For example, if you specified your lookback/in-sample period to be 25 trades, then this means that for every step forward of the walkforward process, each iteration will include the last 25 trades for the in-sample period. In this way each iteration is ensured to be comparing the same number of trades rather than a discrete time period.

Therefore, using Trade Count is not time based, but trades based.  MultiWalk will search the data of each iteration for the previous Trade Count for every step forward of the walkforward process.

Trade count can only be used for lookback (in-sample) periods.  Step-forward (out-of-sample) time points need to be consistent for each optimized iteration and, since, each optimized iteration will contain a different number of trades moving forward in time, it is not possible to have all iterations contain the same number of trades at the same point in time.

Period Units

Period units are simply the number of units to include in each period.  The type of period defines what “unit” means. If you are using Calendar Days, then units refer to the number of days in the period. If you are using Trade Count, then units are the number of trades to include in the period.

Formatting a Single In/Out Period

Periods have “type identifiers”.  If no type is specified, the default period type will be Trading Days so that usage remains consistent with previous versions of MultiWalk.  The following period types can be used:

TD : Trading Days.  Ex: 504/252 or 504TD/252TD, step forward every 252 trading days with a lookback of 504 trading days each time.

D : Calendar Days.  Ex: 20D/1Y, step forward every 20 calendar days with a lookback of 1 calendar year each time.

W : Calendar Weeks.  Ex: 2W/1Y, step forward every 2 calendar weeks with a lookback of 1 calendar year each time.

M : Calendar Months.  Ex: 3M/1Y, step forward every 3 calendar months with a lookback of 1 calendar year each time.

Y : Calendar Years.  Ex: 1Y/1Y, step forward every calendar year with a lookback of 1 calendar year each time.

T : Trade Count.  Ex: 50T/1Y, step forward every calendar year with a lookback of 50 trades each time.

Formatting a matrix of In/Out Periods

Walkforward periods can also be expressed as a matrix.  This makes it possible to do a large run of walkforward periods for comparative analysis without having to enter each walkforward period separately.  The general expression of a matrix is:

[in-sample-start] – [in-sample-end] x [in-sample-step-value] / [out-sample-start] – [out-sample-end] x [out-sample-step-value]

Examples:

15-560×25 / 10-250×10

This will create a 560 in-sample by 250 in-sample trading days matrix of 550 in/out periods starting at 15/10 and ending at 560/250.

2-24x1M / 8-52x2W

This will create a 24 month in-sample by 52 week out-sample matrix of 529 in/out periods starting at 2M/8W and ending at 24M/52W.

 

Table of Contents