Time-in-Force (GTC, FOK, IOC, GTD)
Definition
Time-in-force (TIF) specifies how long an order remains active before automatic cancellation. Common values: GTC (Good 'Til Cancelled) — stays active until filled or manually cancelled; FOK (Fill or Kill) — must fill in full immediately or cancel; IOC (Immediate or Cancel) — fill what's possible immediately, cancel the rest; GTD (Good 'Til Date) — expires at a specified time.
In-depth: Time-in-Force (GTC, FOK, IOC, GTD)
Time-in-force (TIF) is a fundamental order parameter that controls how long an order stays active and what happens if it cannot be filled immediately. The TIF value interacts with order type and market conditions to determine fill behaviour.
Common TIF values:
**GTC (Good 'Til Cancelled):** - Order remains active indefinitely - Cancelled only by explicit cancellation request or by the order filling - Default for many pending orders in MT4/MT5 - Use case: long-term position orders, swing trades, breakout orders that may take days to activate - Risk: orders left active for too long may execute under different market regimes than originally intended; periodic review is essential
**GTD (Good 'Til Date):** - Order expires at a specified date/time - Useful for time-bounded strategies (e.g. orders valid for the current week only) - Common implementation: GTD set to end of week prevents orders carrying over to next week's market regime
**DAY:** - Order active only during the current trading day; cancelled automatically at session close - Common in stock markets; less common in 24-hour forex - 'Day' definition varies by broker — typically broker-defined session close time
**FOK (Fill or Kill):** - Order must fill in its entirety immediately or be cancelled completely - No partial fills allowed - Use case: scalping where partial fills break the trade-management logic; large orders where partial fill would expose the trader to adverse market move on the unfilled portion - Risk: high rejection rate in fast markets where full liquidity at the requested price is not available
**IOC (Immediate or Cancel):** - Order fills whatever is immediately available at the requested price; the unfilled remainder is cancelled - Different from FOK in allowing partial fills - Use case: getting some fill is preferable to no fill; willing to manage a smaller-than-requested position
**FAK (Fill and Kill):** - Functionally similar to IOC; terminology varies by broker
MetaTrader 5 support: - `ORDER_TIME_GTC` — GTC (default) - `ORDER_TIME_DAY` — DAY (cancel at end of trading day) - `ORDER_TIME_SPECIFIED` — GTD (specify exact expiration time) - `ORDER_TIME_SPECIFIED_DAY` — GTD with day-of-trading specifier - `ORDER_FILLING_FOK` — FOK - `ORDER_FILLING_IOC` — IOC - `ORDER_FILLING_RETURN` — partial fills allowed, remainder returned to book
MetaTrader 4 has more limited TIF support — primarily GTC and explicit expiration via `Expiration` parameter.
Use case examples for EAs: - Scalping EA: use FOK to ensure no partial fills (which would break the precise entry logic). Accept higher rejection rate as cost of execution quality. - Swing-trading EA: use GTC for stops and targets that should remain active across days. Use GTD with end-of-week expiration for breakout entries that should not trigger in a different week's regime. - News-trading EA: use IOC for entries during news events — get whatever fill is available immediately, since the trade thesis depends on capturing the move at the news moment. - Large-order EA: use IOC with iterative re-submission, slicing a large order into smaller pieces to manage market impact.