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

# TimeInForce

## Definition

Sets the time in force property for all orders generated by a strategy. The selected TIF parameter is sent to your broker on order submission and will instruct how long you would like the order to be active before it is cancelled.

This property is dependent on what time in force your broker may or may not support. If a brokerage / exchange combination is not compatible with a particular time in force, the order will be rejected by the broker. NinjaTrader does not have a method to prevent an unsupported TIF to be sent to a particular exchange. For questions about what TIF may be supported, please contact your broker directly.

## Property Value

An enum value that determines the time in force. Default value is set to **TimeInForce.Gtc**. Possible values are:

| Property            | Description                                                             |
| ------------------- | ----------------------------------------------------------------------- |
| **TimeInForce.Day** | Orders will be canceled by the broker at the end of the trading session |
| **TimeInForce.Gtc** | Order will remain working until the order is explicitly cancelled.      |
| **TimeInForce.Gtd** | Order will remain working until the specified date                      |

## Syntax

`TimeInForce`

## Examples

### **Setting default TIF for all strategy orders**

```csharp
protected override void OnStateChange()
{
     if (State == State.SetDefaults)
     {
         TimeInForce = TimeInForce.Day;
     }
}
```

### **Setting TIF conditionally**

```csharp
protected override void OnStateChange()
{
     if (State == State.Configure)
     {
         if (Instrument != null)
         {
             if (Instrument.Exchange == Exchange.Nybot)
                 TimeInForce = TimeInForce.Day;
             else if (Instrument.Exchange == Exchange.Globex)
                 TimeInForce = TimeInForce.Gtc;
         }
     }
}
```