> 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.

# OptimizationPeriod

## Definition

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

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

## Property Value

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

## Syntax

`OptimizationPeriod`

## Examples

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