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

# ExitOnSessionCloseSeconds

## Definition

The number of seconds before the actual session end time that the **IsExitOnSessionCloseStrategy** function will trigger.

The time from which this property will be calculated is taken from the [Trading Hours](https://ninjatrader.com/support/helpguides/nt8/?trading_hours.htm) EOD property set in the strategy's Trading Hours template. The ExitOnSessionCloseSeconds property can either be set programmatically in the **OnStateChange()** method or be driven by the UI at run time.

This is a real-time only property, it will not have any effect on your ExitOnSessionClose time in backtesting processing historical data.

## Property Value

An int representing the number of seconds. Default value is 30.

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

## Syntax

`ExitOnSessionCloseSeconds`

## Examples

```csharp
protected override void OnStateChange()
{
     if (State == State.SetDefaults)
     {
         // Triggers the exit on close function 30 seconds prior to trading day end 
         IsExitOnSessionCloseStrategy = true;
         ExitOnSessionCloseSeconds = 30;
     }
}
```