Falling

[[falling]] checks whether a series decreases strictly from one valid value to the next across several consecutive comparisons. It returns 1.0 when the entire sequence is falling and 0.0 as soon as a new valid value is flat or higher.

length counts comparisons, not observed values. With length = 3, the block therefore compares four consecutive valid values: the current value with the previous one, followed by the two preceding pairs.

Block declaration

A strategy can contain multiple [[falling]] blocks. Each block outputs one numeric series, exposed through the block id.

Examples

Minimal setup

This block checks whether the close series falls across three consecutive comparisons.

[[falling]]
id     = "falling"
length = 3

Custom source

This block applies the same test to the hlc3 source.

[[falling]]
id     = "falling_hlc3"
source = "hlc3"
length = 5

Finding the optimal length

This block explores several length values to test different durations of continuous fall.

[[falling]]
id           = "falling"
source       = "close"
length.start = 2
length.stop  = 10
length.step  = 2

Recent fall confirmation

This example uses falling to check that close falls across three consecutive comparisons. The condition becomes true when close_falling is 1.0.

[[falling]]
id     = "close_falling"
source = "close"
length = 3

[[condition]]
id            = "recent_fall_filter"
condition     = "close_falling = 1"
next_block_id = "..."

Parameters

ParameterDescription
id
 String
 Required
Unique identifier for the resulting series.
source
 String
 or Array
 Optional
Input series used for the calculation.
Accepted forms: source = "hl2" or source = ["close", "hl2"].
Each value can be either a standard price source (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume) or the id of another indicator.
Default value: "close"
length
 Integer
 Required
Number of strictly falling comparisons to verify; it must be between 1 and 10000.

Usage:
• Fixed: length = value
• Grid search:
 – length.start = min_value
 – length.stop = max_value
 – length.step = value (optional, default 1)
symbol
 String
 or Array
 Optional
Market symbol(s) used when source only consists of standard prices (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume).
If source mixes standard prices and indicator ids, symbol is applied only to combinations based on standard prices.
If source contains only indicator ids, symbol is ignored.
If symbol is omitted, the block inherits the symbol defined in [backtest].
For symbol format, arrays, and alignment rules, see Exchanges, Symbols and Timeframes.
timeframe
 String
 or Array
 Optional
Timeframe on which this indicator is computed.
If timeframe is omitted, the computation uses the grid’s main timeframe defined in [backtest].
For accepted formats and timeframe alignment rules, see Exchanges, Symbols and Timeframes.

Available variables

Use the identifiers below directly in your expressions. The Falling block exposes one numeric series and its parameters (length, source, symbol, timeframe).

Assume the block is configured as:

[[falling]]
id     = "falling"
length = 3

Then:

VariableDescription
falling or falling[0]
Decimal
Current test value. It is 1.0 when the source falls across length consecutive comparisons, otherwise 0.0.
falling[n]
Decimal
Test value from n candles ago.
falling.length
Decimal
Length used for the current combination.
falling.source
String
Name of the input series.
falling.symbol
String
Market symbol used by this block.
falling.timeframe
String
Timeframe used for the computation.

Notes

  • The falling block always returns a numeric value, either 0.0 or 1.0.
  • NaN values are ignored: they do not break the sequence, and the output retains its state until the next valid value. The next comparison then resumes from the last valid value encountered.
  • Numeric variables can be combined freely in formulas.
  • Text variables are strings intended only for equality and inequality comparisons.