Lowest Bars (lowestbars)
[[lowestbars]] reports where the recent minimum of a series occurred, rather than returning the minimum value itself. On each candle, it finds the lowest value among the last length candles and outputs its offset from the current candle.
The result is 0 when the minimum is on the current candle. Negative values point into the past: -1 is the previous candle, while -3 is three candles earlier. If several candles share the same minimum, the block returns the oldest occurrence that is still inside the window.
source determines the series being examined. With the default low source, the block locates the candle containing the lowest low in the recent window. With close or the output of another indicator, it locates the recent minimum of that series.
Block declaration
A strategy can contain multiple [[lowestbars]] blocks. Each block outputs one numeric series: the offset to the lowest value in the window.
Examples
Minimal setup
This block uses the implicit "low" source and returns the position of the lowest value observed over the last 20 bars.
[[lowestbars]]
id = "lowest_pos"
length = 20Custom source and finding the optimal length
This block computes the position of the minimum close for each length value tested by the grid.
[[lowestbars]]
id = "close_lowest_pos"
source = "close"
length.start = 10
length.stop = 30Position checked in a condition
This example checks whether the lowest value in the window is on the current candle.
[[lowestbars]]
id = "recent_low_pos"
length = 20
[[condition]]
id = "current_low_is_window_low"
condition = "recent_low_pos == 0"
next_block_id = "..."Dedicated symbol and timeframe
This block computes the daily low position for BINANCE:ETHUSDT, independently of the primary symbol and timeframe defined in [backtest]. See Exchanges, Symbols and Timeframes for alignment rules.
[[lowestbars]]
id = "daily_low_pos"
symbol = "BINANCE:ETHUSDT"
timeframe = "D"
length = 20Parameters
| Parameter | Description |
|---|---|
idString Required | Unique identifier for the resulting series. |
sourceString 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: "low" |
lengthInteger 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) |
symbolString 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. |
timeframeString 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
The lowestbars block exposes one numeric series and its parameters (length, source, symbol, timeframe). These variables are available in expressions after the series has been computed.
Assume the block is configured as:
[[lowestbars]]
id = "lowest_pos"
length = 20Then:
| Variable | Description |
|---|---|
lowest_pos or lowest_pos[0]Decimal | Current offset to the minimum of the window. 0 means the minimum is on the current candle; a negative value indicates how many candles separate that minimum from the current candle. |
lowest_pos[n]Decimal | Offset computed n candles ago (e.g. lowest_pos[1] for the previous candle). |
lowest_pos.lengthDecimal | Effective window size. |
lowest_pos.sourceString | Actual source id (low, close, another indicator). |
lowest_pos.symbolString | Display name of the symbol feeding this block. |
lowest_pos.timeframeString | Timeframe used for the computation. |
Notes
The first length - 1 values are not available because the window is not yet complete. After this warm-up, [[lowestbars]] returns 0 when the current source value is NaN.