Cross

[[cross]] is a conditional block that compares two numeric expressions, reference and comparison, evaluated on every candle. Both fields can contain a series, a calculation, or simply a fixed numeric value.

It triggers when a cross is detected in either direction.

Bullish cross:

  • referencet>comparisont
  • referencet-1comparisont-1

Bearish cross:

  • referencet<comparisont
  • referencet-1comparisont-1

When either condition is met, control jumps to the block specified by next_block_id. The block compares expressions evaluated on every candle and covers both bullish and bearish crosses.

Block declaration

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

Example

[[cross]]
id            = "ma_cross"
reference     = "fast_ma"
comparison    = "slow_ma"
next_block_id = "next_block"

Block parameters

ParameterDescription
id
 Text
 Required
Unique identifier of the block.
reference
 Expression
 Required
First numeric expression involved in the cross. It can be a series, a calculation, or a fixed numeric value.
comparison
 Expression
 Required
Second numeric expression compared with reference. It can be a series, a calculation, or a fixed numeric value.
next_block_id
 Text
 Conditional
Required when the [[cross]] 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; it simply controls the execution flow when a crossing happens.