Trade Filter By State
The Trade Filter By State rule filters trades based on changes in their state values compared to the previous state. It is designed to identify trades experiencing specific patterns of change — such as rising profit, tightening stop losses, or decreasing position size — by continuously comparing current values against previously recorded values.
How It Works
The Trade Filter By State rule monitors trades and compares their current state values with their previous state values to identify specific patterns of change. When activated, the rule tracks how a particular attribute of each trade evolves over time, comparing the current value to the last recorded value for that attribute.
You can monitor a range of trade attributes, including current profit or loss (in monetary terms or in pips), stop loss price or distance in pips, take profit price or distance in pips, and the remaining open quantity of the trade. For each attribute, the rule compares the current value to the previously recorded value using the comparison operator you specify (equal, less than, greater than, and so on).
This enables sophisticated monitoring of trade state changes. For example, you could identify trades where the profit has increased compared to the previous state (using the "Greater Than" operator), or where the take profit has been moved closer to the current price (using "Less Than" on take profit pips).
The rule also includes a consecutive match counter. You can require a specific number of consecutive matching states before a trade is included in the output. This helps avoid false triggers and ensures that only trades showing consistent state patterns are selected. The rule maintains an internal record of each trade's previous state and match count to enable this functionality over time.
Inputs
| Parameter | Description | Required | Default |
|---|---|---|---|
| Trade Id(s) | The list of trade IDs that will be evaluated based on their state changes compared to their previous states. | Yes | — |
| Filter By | Specifies which trade attribute to monitor for changes between the current and previous states. Options: Profit (monetary profit/loss), Profit Pips (profit/loss in pips), Stop Loss Price, Stop Loss Pips (SL distance in pips), Take Profit Price, Take Profit Pips (TP distance in pips), Open Quantity (remaining open volume). | Yes | Profit |
| Operator | The comparison operation to use when comparing the current state value to the previous state value. Options: Equal, Less Than Or Equal, Less Than, Greater Than, Greater Than Or Equal, Not Equal. | Yes | — |
| Counter | The number of consecutive times a trade must meet the state comparison conditions before it is included in the output. Higher values ensure more consistent patterns and reduce false triggers. | Yes | 1 |
Outputs
| Output | Description |
|---|---|
| Filtered Trade Id(s) | The list of trade IDs where the specified state attribute has consistently matched the comparison criteria for the required number of consecutive checks. |
| Filtered Trade Id Count | The number of trade IDs that matched the specified state comparison criteria. Useful for conditional logic or verifying results downstream. |
Tips
Increase the Counter value to require more consecutive matches before a trade qualifies. For example, setting the counter to 3 with "Greater Than" on Profit ensures that a trade's profit must increase for three consecutive evaluations before it appears in the output. This is a great way to confirm that a trade is genuinely trending in the desired direction before taking action such as tightening a trailing stop.
Was this helpful? Let us know