Trade Filter By Time
The Trade Filter By Time rule filters a list of trades based on specific time criteria. It supports strategies that depend on timing by enabling you to find the earliest or latest trades, or trades that occurred before or after specific time periods, with configurable time windows down to the second.
How It Works
The Trade Filter By Time rule takes a collection of trade IDs and applies time-based filtering criteria to return the subset of trades that match your specified conditions. You begin by specifying which trade IDs to consider, then narrow down based on trade characteristics such as direction (buy or sell), order type, and whether you are looking at orders or positions.
For positions, you can filter based on entry time, when take profit orders were placed or modified, or when stop loss orders were placed or modified. For orders, you can filter based on when orders were placed.
The rule provides three filtering approaches:
- First — Selects the trade with the earliest time for the specified criterion.
- Last — Selects the trade with the latest time for the specified criterion.
- Condition — Selects trades based on a target date and time, with the option to match trades that occurred before or after that moment. You can also define a time window (for example, trades that occurred at least 5 minutes after the target time) using the period and period count settings.
The execution mode controls output: "Single Or None" returns a single trade only if there is exactly one match, "Single" returns any single trade from the matches, and "All Matches" returns every matching trade. The match count option limits how many times a particular trade can be considered by this rule, preventing the same trade from being reused across multiple evaluations.
Inputs
| Parameter | Description | Required | Default |
|---|---|---|---|
| Trade Id(s) | The list of trade IDs that will be evaluated and filtered based on the specified time criteria. | Yes | — |
| Execute On | Determines how many trade IDs the rule should return. Options: Single Or None (returns one trade if exactly one matches, or none if multiple match), Single (returns one trade even if multiple match), All Matches (returns all matching trades). | Yes | Single Or None |
| Match Type | Controls whether the rule can be applied to the same trades multiple times. Options: Every time (matches all qualifying trades without restriction), Up to count (limits how many times a trade can be matched). | Yes | Every time |
| Match Count | The maximum number of times a trade can be matched by this rule. Shown when Match Type is set to "Up to count". | No | — |
| Filter | Determines whether to filter by order or position characteristics. Options: Order (filter based on order details such as placement time), Position (filter based on position details such as entry time or SL/TP placement). | Yes | Position |
| Side | Filters trades by direction. Options: Buy, Sell, Any. | Yes | Any |
| Order Type | Filters by order type. Options: Stop, Limit, Market, Any, Stop Limit, Limit Stop. Shown when Filter is set to Order. | No | Limit |
| Filter By | The time-based selection method. Options: First (earliest trade), Last (latest trade), Condition (trades before or after a specific date/time with an optional time window). | Yes | First |
| Filter On | The specific time aspect to evaluate. For positions: Entry Time, Take Profit Placed Time, Take Profit Modified Time, Stop Loss Placed Time, Stop Loss Modified Time. For orders: Order Placed Time. | No | Entry Time |
| Period | The time unit for the window used in conditional filtering. Options: Days, Hours, Minutes, Seconds. Shown when Filter By is Condition. | No | Days |
| Period Count | The number of time periods to use in the time window for conditional filtering. Shown when Filter By is Condition. | No | — |
| Operator | Specifies whether to match trades that occurred after or before the target time plus the period. Options: After, Before. Shown when Filter By is Condition. | No | — |
| Target Date Time | The reference date and time to compare against when using conditional filtering. Shown when Filter By is Condition. | No | — |
Outputs
| Output | Description |
|---|---|
| Filtered Trade Id(s) | The list of trade IDs that matched the specified time-based filtering criteria. |
| Filtered Trade Id Count | The number of trade IDs that matched the filtering criteria. Useful for conditional logic or verifying the expected number of results. |
Tips
Use the "First" filter to find the oldest open trade (useful for FIFO exit strategies) or "Last" to find the most recently opened trade. For time-decay strategies, use the Condition mode with the "After" operator and a period of Hours to identify positions that have been open for a minimum duration before applying take-profit adjustments.
Was this helpful? Let us know