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
Required when the [[position]] 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.

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"