NinjaTrader 8 Time in Force: GTC vs Day for Automated Strategies

You hold a long NQ position into the late afternoon with a stop working underneath it. The session ends. The next time you look at the account, the position is still open and the stop is gone. Nothing crashed and nothing was hacked. The stop was a Day order, and your broker did exactly what a Day order asks for.

That is time in force, usually shortened to TIF. It is one small setting on every NinjaTrader 8 strategy, and it tells your broker how long each order is allowed to live. This guide covers what the Help Guide says about the three values, the other mechanisms in NinjaTrader that cancel orders (there are more than most people expect), and how we think about GTC versus Day on a prop firm account.

What Time in Force Does

NinjaTrader's TimeInForce documentation says the property "sets the time in force property for all orders generated by a strategy." The selected value is sent to your broker when the order is submitted, and it instructs how long you would like the order to be active before it is cancelled.

Two details in that definition matter.

The property has three possible values.

Value What the Help Guide says What ends the order
TimeInForce.Day Orders will be canceled by the broker at the end of the trading session A fill, a cancel, or the end of the session
TimeInForce.Gtc Order will remain working until the order is explicitly cancelled A fill or a cancel
TimeInForce.Gtd Order will remain working until the specified date A fill, a cancel, or the date passing

The default is TimeInForce.Gtc, which stands for good till cancelled. If nobody has touched the setting, your strategy's orders are GTC. The rest of this article deals with the two values traders choose between in practice: GTC and Day.

Where You Set It

There are two places, depending on whether you wrote the strategy.

In the strategy's properties

When you add a strategy to a chart or to the Control Center's Strategies tab, the properties window includes an order properties group with a Time in force field. The Help Guide's page on running a NinjaScript strategy from a chart describes it in one line: it sets the order's time in force, and the possible values are DAY and GTC.

In code

If you write your own strategies, you set the default in OnStateChange(). This is the pattern from the Help Guide:

if (State == State.SetDefaults)
{
    TimeInForce = TimeInForce.Day;
}

The Help Guide's second example is worth a look too. It sets the value in State.Configure based on the instrument's exchange, using Day for one exchange and GTC for another. The message behind that example is that time in force is a per-market, per-broker decision, and one value will not suit every route.

Time in Force Is One of Four Clocks

Here is the part that causes most of the confusion. A working order from a NinjaTrader strategy can be cancelled by four different mechanisms, and only one of them is time in force. When an order disappears, you need to know which clock ran out.

1. The bar close

Most strategies use what NinjaScript calls the managed approach. The Help Guide's Managed Approach page explains that, by default, orders are kept alive provided they are re-submitted on each call of OnBarUpdate(). If an order is not re-submitted, it is cancelled. The same page lists it as a rule: orders submitted through the entry and exit methods automatically cancel at the end of a bar if not re-submitted.

So a limit entry that lasts one bar and then vanishes has nothing to do with GTC or Day. The strategy stopped asking for it.

Developers can switch that off per order. Each order method has an overload that submits a "live until cancelled" order, which stays working until the code calls CancelOrder(). Even then, time in force still applies:

"Orders can remain live until you call the CancelOrder() method, or until the order's time in force has expired, whichever comes first." (NinjaTrader 8 Help Guide, Advanced Order Handling)

A live until cancelled order with a Day time in force is still gone at the end of the session.

2. Time in force at the broker

This is the clock from the table above. Day orders are cancelled by the broker at the end of the trading session. GTC orders are not.

3. Exit on session close

NinjaTrader has its own end-of-session cleanup, and it is switched on by default. The Help Guide says IsExitOnSessionCloseStrategy determines whether the strategy will cancel all strategy generated orders and close all open strategy positions at the close of the session. Its default value is true.

A companion property, ExitOnSessionCloseSeconds, sets how many seconds before the session end that cleanup triggers. The default is 30. The Help Guide adds that the session end time is taken from the Trading Hours template the strategy runs on, and that this is a real-time only property. It has no effect on the exit time when a backtest processes historical data.

Put those together. On a strategy with Exit on session close left on, the strategy itself cancels its working orders shortly before its session ends. In that setup your orders are normally gone before a Day time in force would have removed them. Time in force starts to matter when Exit on session close is off, or when the session in your template ends at a different time from the session your broker uses. We covered how the template defines that session in our guide to NinjaTrader 8 Trading Hours templates.

4. Disabling the strategy

The fourth clock is you. NinjaTrader's strategy settings include two options: Cancel entry orders when a strategy is disabled and Cancel exit orders when a strategy is disabled. Each one sets whether NinjaTrader automatically cancels that type of order when you disable the strategy.

If either option is off, disabling the strategy leaves those orders working. With a GTC time in force, they stay at the broker until something cancels them. Check both settings before you assume that unticking Enabled cleans everything up.

A cancel is a request

The Help Guide's CancelOrder() page notes that the method sends a cancel request to the broker and does not guarantee that an order is completely cancelled. An order can be filled or part filled between the time you send the cancel request and the time the exchange receives it. The same logic applies at the end of a session. Do not treat an order as gone until the Orders tab shows it as cancelled.

When Your Broker Does Not Support the Value

The TimeInForce page carries a note that deserves more attention than it gets. The property depends on what time in force your broker supports. If a brokerage and 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 value from being sent, and the Help Guide tells you to contact your broker with questions about what is supported.

A rejection is a bigger event for a strategy than it sounds. The RealtimeErrorHandling documentation describes the default behavior when a strategy generated order comes back from the broker's server in a rejected state. The strategy stops, cancels any remaining working orders, and then closes any open positions it manages.

So an unsupported time in force can look like a strategy that disables itself the first time it tries to trade. If that is what you are seeing, check the Log tab for the rejection message before you change anything else. Our checklist for why a NinjaTrader 8 strategy stopped trading walks through the other causes of a strategy that shuts itself off.

This is also a reason to ask the question up front. A simulation account is not your broker's order route, so a value that works in simulation tells you little about what the live connection accepts. Ask your broker or your prop firm's support which time in force values they take, and get the answer in writing if you can.

ATM Strategies Take It From the Order Entry Window

ATM strategies handle time in force differently. In the Help Guide's ATM strategy parameters, TIF is listed as "copied from the order entry window," and it sets the time in force for the entry, profit target and stop loss orders.

If you place trades by hand from Chart Trader or the SuperDOM and let an ATM strategy manage the stop and target, the value comes from that order entry window. The setting inside a NinjaScript strategy's properties does not apply to it. We compared the two approaches in ATM strategy vs NinjaScript strategy.

Want a strategy that is ready to run?

NQ Ultra is a ready-to-run NinjaTrader 8 strategy for NQ futures, built for traders running prop firm accounts. Start from a finished system instead of debugging order handling.

Get NQ Ultra on Whop

GTC or Day on a Prop Firm Account?

What follows is our view, not NinjaTrader's. If the strategy you run came with setup instructions, use the vendor's recommended time in force first, because the strategy was built and tested around it.

For an intraday strategy with Exit on session close on, both values work. The strategy cancels its own orders and flattens before the session ends, so in normal operation the time in force never gets to decide anything. The difference shows up when something goes wrong.

Day gives you a broker-side backstop for stray entries. Suppose your strategy has a resting limit entry working when your PC loses power. NinjaTrader is no longer running, so nothing on your side can cancel that order. If it is a Day order, the broker removes it at the end of the session. If it is GTC, it can sit there and fill later with no strategy running to place a stop behind it. On an account with a daily loss limit or a trailing drawdown, an unmanaged position is the worst kind to hold.

GTC protects a position you mean to hold past the session end. Go back to the opening example. Suppose a strategy has Exit on session close turned off and holds a position through the end of the session with a Day stop. The broker cancels the stop at the end of the session and the position stays open with nothing protecting it. If your strategy is designed to hold across sessions, its protective orders need to outlive the session, and that means GTC.

Check your firm's rules on holding and on resting orders. If your firm requires you to be flat by a set time each day, a resting GTC entry order that fills after that time is a position you were not supposed to have. Read the firm's current rules page yourself. Third-party summaries of prop firm rules go stale quickly.

Restarts add one more wrinkle. A GTC order left at the broker is still there when you start NinjaTrader again, and what the strategy does about it depends on its start behavior setting. We went through that in NinjaTrader 8 Start behavior explained.

A Short Time in Force Checklist

  1. Find out what your strategy uses. Open the strategy's properties and read the Time in force field. If it was never changed, it is GTC.
  2. Ask your broker or firm which values it accepts. An unsupported value is rejected by the broker, and a rejected order stops the strategy by default.
  3. Check Exit on session close. Know whether it is on, how many seconds before the session end it triggers, and which Trading Hours template supplies that session end.
  4. Check the two cancel-on-disable settings. Decide on purpose whether disabling a strategy should cancel its entry orders, its exit orders, or both.
  5. Look at the Orders tab after the session ends. Nothing should be working unless you intended it to be. If something is, work out which of the four clocks failed to cancel it.
  6. Test the failure case in simulation. Place a resting order, close the platform, and see what is left when you come back. Remember that the live broker may treat the same order differently.

Time in force is easy to skip because the default works on most days. It earns its keep on the bad day: the power cut, the dropped connection, the strategy you disabled in a hurry. Know which value your strategy sends, know which of the four clocks is supposed to cancel each order, and confirm with your broker that the value you picked is one it will accept.