PyneCore v6.5.6
This release focuses on TradingView parity: strategy margin-call and exit-leg sizing, session/date-string handling, request.* graceful degradation, cross-symbol request.security() correctness, and several series-history and rolling-ta.* fixes.
Strategy / broker emulator
- Sub-lot margin calls now trim exactly one whole contract capped by the current position size (
min(1.0, quantity)), both at the bar open and intrabar, matching TradingView (the Gaussian Channel corpus shows 43 such single-contract trims on 8+ contract positions). strategy.exitqty/qty_percentlegs bound to one entry are capped at the unreserved entry remainder (min(requested, init_size - sibling_reservations)), and create no order when that remainder is<= 0, matching TradingView's first-come-first-served leg reservation.strategy.close/strategy.close_all(immediately=true)fills are deferred to after the script body: the position settles at the bar close but stays script-visible until the next bar, soposition_size-gated plots/expressions after the close call no longer read the flat position one bar early. Exit price, P&L and cumulative stats are bit-identical; only the timing moves.- Below
1e7order money, a market entry snaps up to the next lot when the raw money-tick count reaches the0.05-tick floor cell (measured[1e8, 1.16e8]cost band); the snapped size still faces the ordinary creation-time margin check at the placement close.
request.security() / cross-symbol
- Gap-compact a same-TF cross-symbol security child (e.g.
TVC:US10Y@30on a 24/7BINANCE:BTCUSDT@30chart): stateful indicators (ta.ema,ta.atr) inside the child no longer run over synthetic weekend/overnight fill bars, so indicator state freezes between real bars and forward-fills (gaps_off) / emitsna(gaps_on) like TradingView.
Builtins / lib parity
label.set_textcolorkeyword parameter renamedcolor->textcolor(Pine v6 name); previously raisedTypeErroron the named call.str.tostringsecond parameter renamedfmt->format(Pine v6 name); previously named-argument calls (str.tostring(x, format=format.percent)) raisedTypeError.request.seed()returnsnainstead of raising (seed data lives in TradingView-hosted community repositories PyneCore cannot access), mirroringrequest.footprint().request.financial()gains explicit named parameters and returnsnawhenignore_invalid_symbolis set, mirroringrequest.earnings().string.format/str.tostringpropagatenawhen the format pattern isna.math.sumperiodically resyncs its sliding window from the buffer so residual Kahan rounding no longer breaks TradingView-preserved identities (flat windows now sum exactly ton*v).array.covarianceuses the Welford online co-moment to match TradingView bit-for-bit on the unbiased path.
Sessions / date parsing
session.islastbar_regular/islastbarnow fire on 24/7 markets: a session end at midnight (00:00=24:00) is rolled forward one day so the closing-bar window matches; strategies gating on it (e.g. a Friday-close hard exit) no longer strand positions.- A
"0000-0000"session (start equals end, theinput.sessiondefault) spans the full 24 hours: every bar on an allowed weekday now qualifies instead of being reported out of session (which previously placed zero trades). parse_datestringaccepts ISO datetimes without seconds ("2021-01-01 00:00", both space andTseparators) and space-separated numeric dates ("05 12 2000"is May 12, month-first; day-first"31 1 2000"stays rejected), verified live on TradingView.
Series / transformers
- Tuple-unpacked series variables (
a, b = f()) now record per-bar history: previously the slot buffer never advanced anda[1]was permanentlyna. - A parent-scope series indexed only from inside a nested function is no longer pruned to a scalar (which crashed with
'float' object is not subscriptable); index usage propagates up the scope chain. - Rolling
ta.*(sma,wma,cog,stdev,variance,bb,bbw,kc,correlation,change,roc) no longer collapse tonaforlength > 500: the indexed buffer grows withmax_bars_back(series, length);length > 5000now raises, matching Pine's own ceiling. DynamicDefaultTransformerevaluateslib.*-referencing parameter defaults (e.g.source = hl2) per call rather than at def time, so anchored library call sites no longer freeze the first bar's value.