Trend

[[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 when referencet>referencet-1
  • direction = "bearish": the condition is true when referencet<referencet-1

When the condition is true, the block validates on that candle. If it is used on its own, execution moves to the block referenced by next_block_id. If it is used as a child condition inside a logical block, it simply contributes to the validation of the parent block.

This block does not try to identify a broader trend or a full reversal. It only checks whether a single expression is rising or falling between two consecutive candles.

The comparison uses values already observed from one candle to the next. It therefore does not take into account changes produced later in the processing of the same candle.

You can use [[trend]] either as a standalone block or as a child condition inside [[and]] or [[or]]. When it is used on its own, next_block_id is required. When it is used inside a logical block, this field must be omitted because the parent block controls the transition.

Block declaration

A strategy can contain multiple [[trend]] blocks.

Standalone example:

[[trend]]
id            = "my_trend"
direction     = "bullish"
reference     = "ema_fast - ema_slow"
next_block_id = "next_block"

Example inside an [[and]] block:

[[and]]
id            = "entry_filters"
conditions    = ["trend_ok", "volatility_ok"]
next_block_id = "open_long"

[[trend]]
id        = "trend_ok"
direction = "bullish"
reference = "ema_fast - ema_slow"

Block parameters

ParameterDescription
id
 Text
 Required
Unique identifier of the block.
direction
 Text
 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.
reference
 Text
 Required
Numeric expression evaluated on each candle and compared with its own value on the previous candle.
next_block_id
 Text
 Conditional
Required when the [[trend]] block is used on its own. Must be omitted when it is used as a child of an [[and]] or [[or]] block.

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.