TimeInForce

View as Markdown

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:

PropertyDescription
TimeInForce.DayOrders will be canceled by the broker at the end of the trading session
TimeInForce.GtcOrder will remain working until the order is explicitly cancelled.
TimeInForce.GtdOrder will remain working until the specified date

Syntax

TimeInForce

Examples

Setting default TIF for all strategy orders

1protected override void OnStateChange()
2{
3 if (State == State.SetDefaults)
4 {
5 TimeInForce = TimeInForce.Day;
6 }
7}

Setting TIF conditionally

1protected override void OnStateChange()
2{
3 if (State == State.Configure)
4 {
5 if (Instrument != null)
6 {
7 if (Instrument.Exchange == Exchange.Nybot)
8 TimeInForce = TimeInForce.Day;
9 else if (Instrument.Exchange == Exchange.Globex)
10 TimeInForce = TimeInForce.Gtc;
11 }
12 }
13}