Trend
On this page
[[trend]] is a conditional block that compares the numeric value of reference on the current candle with its value on the previous candle.
The direction key defines the comparison:
direction = "bullish": the condition is true whendirection = "bearish": the condition is true when
As long as the trend of reference does not match the requested direction, the block stays pending and evaluation continues on the next candle. The block is validated as soon as that trend matches the requested direction. Execution then continues with the block identified by next_block_id.
Block declaration
A strategy can contain multiple [[trend]] blocks.
Examples
Direct use
This example shows a [[trend]] block used directly in the strategy flow. The strategy moves to next_block only when ema_fast - ema_slow moves upward from one candle to the next.
[[trend]]
id = "my_trend"
direction = "bullish"
reference = "ema_fast - ema_slow"
next_block_id = "next_block"Use inside [[and]]
This example shows a [[trend]] block evaluated by a parent [[and]] block. The [[trend]] block does not define next_block_id; flow is controlled by the parent [[and]].
[[and]]
id = "entry_filters"
condition_ids = ["trend_ok", "volatility_ok"]
next_block_id = "open_long"
[[trend]]
id = "trend_ok"
direction = "bullish"
reference = "ema_fast - ema_slow"Block parameters
| Parameter | Description |
|---|---|
idText Required | Unique identifier of the block. |
directionText Required | Expected direction of change: "bullish" when the current value must be strictly greater than the previous one, "bearish" when it must be strictly lower. |
referenceText Required | Numeric expression used as the trend to test. Its current value is compared with its previous value. |
next_block_idText Conditional | Identifier of the next block to execute once the requested movement is observed and the block is validated. Must be omitted when the block is used as a child of an [[and]] or [[or]] block. Must be defined when the block is used as a direct child of a [[route]] block, because [[route]] follows the selected child’s next_block_id. |
The [[trend]] block does not produce any output variable. It is only used to move execution forward when the monitored expression changes in the requested direction between the current candle and the previous one.