Position

[[position]] is a conditional block that evaluates reference and comparison on every candle.

The position key defines the direction of the test:

  • position = "above": the condition is true when reference>comparison.
  • position = "below": the condition is true when reference<comparison.

When the condition is true, execution jumps to the block referenced by next_block_id. This block checks an instantaneous relative position and does not detect crossover events (use [[crossover]] or [[crossunder]] for that).

Block declaration

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

Example

[[position]]
id            = "trend_filter"
position      = "above"
reference     = "close_price"
comparison    = "ma_fast"
next_block_id = "next_step"

Block parameters

ParameterDescription
id
 Text
 Required
Unique block identifier.
position
 Text
 Required
Comparison direction: "above" or "below".
reference
 Text
 Required
Reference expression evaluated on each candle.
comparison
 Text
 Required
Expression compared to the reference.
next_block_id
 Text
 Conditional
Identifier of the next block to execute once the relationship between reference and comparison is true 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.

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

Equivalent with [[condition]]

The [[position]] block is a readable shortcut for a strict comparison between two expressions evaluated on each candle.

Equivalent for position = "above":

[[condition]]
id            = "trend_filter"
condition     = "close_price > ma_fast"
next_block_id = "next_step"

Equivalent for position = "below":

[[condition]]
id            = "trend_filter"
condition     = "close_price < ma_fast"
next_block_id = "next_step"