v6.5.5 — TradingView parity: strategy sizing, request.security multi-context, builtin compatibility
This release focuses on TradingView parity — closing strategy-sizing and request.security() multi-context edge cases — alongside several builtin/lib compatibility fixes and two robustness fixes that stop runaway CPU/memory.
Strategy / broker emulation
- Same-direction market entries that clear their own placement-time 100%-equity check but over-margin at bar open only because an earlier same-bar entry already grew the position are now filled (both legs pass their own bar-start check, and the bar-open margin call trims the aggregate), matching TradingView. The sub-
1e7fill-margin tolerance was tightened from7.5e-10to1e-11so real overages are rejected while float noise still fills. - A default-sized (
percent_of_equity/ cash) price-based entry that re-resolves to a larger quantity at the fill price now has its no-qty bracket exit grow with it, so one exit closes the whole fill instead of stranding a sliver that surfaced as a spurious extra trade.
request.security() / multi-context correctness
timeframe.main_periodnow reports the chart's main-series timeframe inside arequest.security()child. Previously it fell back to the child's own period, so atimeframe.change(timeframe.main_period)reset key (the canonical up/down-volume accumulator) reset every intrabar instead of once per chart bar.- Fixed three bugs blocking nested
request.security()scripts:timeframe.main_periodused as a security timeframe argument at module-exec time no longer crashes;string.matchnow translates Pine's\zregex escape to Python's\Z; and the security protocol is now injected into imported library modules, so a library that itself callsrequest.security()no longer raisesNameError. --securitypath resolution no longer mangles symbols containing a dot (e.g. a perpetualBINANCE:BTCUSDT.P); the dotted stem previously resolved to a non-existent.ohlcvfile and aborted the run with "Security data not found".last_bar_timeis now anchored to the chart's final historical bar (Pine's whole-history-known semantics), with live runs still tracking the realtime bar.chart.left_visible_bar_time/right_visible_bar_timeare rebased on it so right-edge viewport comparisons fire correctly.
Builtins / lib compatibility
array.max(id, nth)andarray.min(id, nth)now accept Pine v6's optional 0-basednthrank (na elements ignored);array.max(id, 0)no longer raises aTypeError.lib_math.sum(and through itta.sma/ta.rsi/ta.mfi) now supports a varying serieslength(e.g.ta.sma(src, ta.barssince(cond))); a per-bar-changing window previously produced garbage. The constant-length O(1) fast path is unchanged.- Bare
ta.vwapnow works as the Pine built-in variable form (session-anchored VWAP ofhlc3), not only theta.vwap(source)function form. request.footprint()now returnsna(with a workingnot na(fp)guard and a newFootprint.total_volume()accessor) instead of raising, so footprint scripts that guard their reads keep running on data without tick-level order flow.
Robustness
- Iterating an
NAor aSeriesthrough the sequence protocol (str.join(na),list(na), tuple unpacking) no longer spins forever at 100% CPU:NA.__iter__now raises loudly,SeriesImpliterates newest-to-oldest and terminates, andstring.repeat/string.replaceguard na inputs. - An orphaned
request.security()child process now self-terminates within ~2s when its parent is hard-killed (SIGKILL or a subprocess timeout). On macOS such an orphan previously spun at 100% CPU and pinned its OHLCV + interpreter memory, enough to exhaust RAM and freeze the host. - Volume is restored to feed precision on read via
_round_volume, removing the ~1e-7float32 dust that accumulated in every volume sum.