Skip to content

request.security_lower_tf(..., ignore_invalid_timeframe=true) returns scalar NaN where a tuple of arrays is expected #258

Description

@port2life

Environment

  • PineTS 0.9.28, Node v25.9.0, chart timeframe "1" (1-minute), plain OHLC candles.

Minimal reproduction (chart TF = 1m, so the requested "5" is higher, i.e. invalid for LTF)

//@version=6
indicator("repro")
[h, l, t] = request.security_lower_tf(syminfo.tickerid, "5", [high, low, time], ignore_invalid_timeframe = true)
plot(array.size(h))

Observed

Cannot read properties of undefined (reading 'size')

Expected

With ignore_invalid_timeframe = true, TradingView returns empty arrays — the script's
own array.size(...) == 0 guards then work. It must not throw.

Analysis (from the published source map)

security_lower_tf.ts (~line 327): if (reqTimeframeIdx > ctxTimeframeIdx) { if (_ignore_invalid_timeframe) return NaN; ... } — a scalar NaN where the tuple contract
requires the nested-array shape produced by the function's own same-timeframe branch a
few lines below. The transpiled destructure then yields undefined for each element and
the first array.* consumer throws.

Suggested fix

Return the same shape as the same-timeframe branch but with empty PineArrayObjects
(one per requested tuple element) — Pine-faithful, and lets user guards fire.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions