Highest

[[highest]] produces the rolling upper bound of a series. On each candle, it returns the highest value in the window formed by the last length candles. The current candle is part of that window, so a new maximum appears in the output immediately.

The bound remains unchanged until a higher value enters the window or the existing maximum leaves it. When that maximum drops out, the largest remaining value takes its place. Unlike an average, [[highest]] does not combine the observations in the window: it retains only the upper extreme. With the default high source, that extreme is the highest recent high; with another source, it is the recent maximum of that series.

Block declaration

A strategy can contain multiple [[highest]] blocks. Each block outputs one numeric series: the rolling maximum value.

Examples

Minimal setup

This block uses the implicit "high" source, so it tracks the highest value observed over the last 20 bars.

[[highest]]
id     = "highest"
length = 20

Custom source and finding the optimal length

This block explores a range of values for length on the close series to identify the best-performing length.

[[highest]]
id           = "highest"
source       = "close"
length.start = 10
length.stop  = 30

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: "high"
length
 Integer
 Required
Window size; must be ≥ 1.

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.
When omitted, the block inherits the [backtest] symbol.
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 highest block exposes one numeric series and its parameters (length, source, symbol, timeframe).

Assume the block is configured as:

[[highest]]
id     = "highest"
length = 20

Then:

VariableDescription
highest or highest[0]
Decimal
Current rolling maximum. First valid sample appears after length - 1 candles.
highest[n]
Decimal
Value n candles ago (e.g. highest[1] for the previous bar).
highest.length
Decimal
Effective window size used during the current combination.
highest.source
String
Actual source id (high, close, another indicator).
highest.symbol
String
Display name of the symbol feeding this block.
highest.timeframe
String
Timeframe used for the computation.