Trailing

[[trailing]] is a conditional block that monitors expression and tracks a running extreme based on position.

  • position = "above": expressionthighest×(1-threshold100)
  • position = "below": expressiontlowest×(1+threshold100)

Here, highest is the running high and lowest is the running low tracked since the block became active.

The absolute value of threshold is reevaluated each time the block executes, then used as the current percentage. When the condition is true and the block is used on its own, execution jumps to the block referenced by next_block_id. When the block is used as a child of [[and]] or [[or]], it does not drive the transition itself; it only contributes to the validation of the parent block. After a trigger, the trailing state is reset.

When the block is used inside [[and]] or [[or]], it is evaluated only if the parent’s logical short-circuit actually reaches it on the current candle.

Block declaration

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

Example

[[trailing]]
id            = "trail_exit"
position      = "above"
expression    = "close_price"
threshold     = 1.5
next_block_id = "next_step"

Example with a computed threshold:

threshold = "(atr / close_price) * 100"

Block parameters

ParameterDescription
id
 Text
 Required
Unique block identifier.
position
 Text
 Required
Trailing mode: "above" or "below".
expression
 Text
 Required
Expression monitored on each candle.
threshold
 Numeric expression
 Required
Pullback/rebound percentage that triggers the block.
next_block_id
 Text
 Conditional
Required when the [[trailing]] block is used on its own. Must be omitted when it is used as a child of an [[and]] or [[or]] block.

This block does not produce any output variable; it only controls execution flow.