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 .position = "below": the condition is true when .
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
| Parameter | Description |
|---|---|
idText Required | Unique block identifier. |
positionText Required | Comparison direction: "above" or "below". |
referenceText Required | Reference expression evaluated on each candle. |
comparisonText Required | Expression compared to the reference. |
next_block_idText 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"