Crossover

[[crossover]] is a conditional block evaluating two expressions, reference and comparison, on every candle.

It triggers when reference rises above comparison after being below or equal on the previous candle. In other words:

  • referencet>comparisont
  • referencet-1comparisont-1

When the condition is met, control jumps to the block specified by next_block_id. This implements a classic bullish crossover test, for example a fast moving average crossing above a slow one. The block compares expressions evaluated on every candle.

Block declaration

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

Example

[[crossover]]
id            = "cross_ma"
reference     = "ma_fast"     # expression A
comparison    = "ma_slow"     # expression B
next_block_id = "next_block"

Block parameters

ParameterDescription
id
 Text
 Required
Unique identifier of the block.
reference
 Expression
 Required
Numeric expression that must cross above comparison. It can be a series, a calculation, or a fixed numeric value.
comparison
 Expression
 Required
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 [[crossover]] 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 the execution flow based on a bullish crossover.