> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# TestPeriod

## Definition

Reserved for **Walk-Forward Optimization**, this property determines the number of days used for the "out of sample" backtest period for a given strategy. See also **OptimizationPeriod**.

This property should ONLY be called from the **OnStateChange()** method during State.SetDefaults.

## Property Value

An **int** value representing the number of "out of sample" days used for walk-forward optimization; Default value is set to 28.

## Syntax

`TestPeriod`

## Examples

```csharp
protected override void OnStateChange()
{
    if (State == State.SetDefaults)
    {         
        //set the default TestPeriod to 31 days for WFOs
        TestPeriod = 31;
    }
}
```