You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
strategy() defaults follow the current Pine v6 values
initial_capital is now 100000 (was 1000000), default_qty_type is strategy.percent_of_equity (was strategy.fixed) and default_qty_value is 100 (was 1). A strategy that relies on the defaults and does not set these arguments now sizes its orders differently; set them explicitly to keep the previous results. The strategy defaults are listed in the script format reference.
Fixes
Strategy
Margin-reject order handling matches TradingView: a market reversal that cannot be margined when placed closes the old position and opens nothing; a strategy.order whose resulting net position cannot be margined is rejected whole; a reversal rejected at its fill withdraws the remaining position's strategy.exit orders until its next margin call; margin-call cover lots are a plain truncation.
A strategy.exit without from_entry whose entry was margin-rejected is re-aimed at the next position in both directions, stays close-only, survives opening gaps, and yields to an exit that names the position's entry.
process_orders_on_close: the deferred margin call runs before the close-time orders, so a position opened at the close is first margin-checked at the next open.
A default-sized (percent_of_equity / cash) stop order that the next open gaps through is sized at the price it would have executed at when it was placed, plus slippage, instead of at the open it fills at. Applies to strategy.entry and strategy.order.
A partial market strategy.close() that fired its whole slice no longer re-fills as a no-op on every later bar. With calc_on_order_fills those phantom fills re-ran the script, so a later strategy.close_all filled one bar early. Verified against TradingView (934 trades).
New close_by_id switch of the strategy decorator keeps Pine v4/v5's strategy.close() order slots: every same-bar close of one entry id modifies a single pending order, while v6 gives each close statement its own. PyneComp emits it for v4/v5 sources.
A replaced or cancelled immediately=True close no longer fills from the deferred buffer, and the calc_on_order_fills re-execution cleanup no longer removes the order that took over its slot.
ta
ta.highest, ta.lowest, ta.highestbars, ta.lowestbars and ta.linreg pick their machine from the Pine qualifier of length, as TradingView does: a const, input or simple length keeps a length + 1 ring written only on the bars the call runs, while a series length forward-fills the bars a conditional call skips and reads the full history when the length grows. The qualifier is derived by the type inference, so hand-written Pyne code gets the same machine as converted code.
ta.linreg stores an na like any value, and a window holding one answers na.
request
A script declared with calc_bars_count = N calculates every request.security() and request.security_lower_tf() context only on the last max(1, floor(N * chart_tf / context_tf)) bars of the context's own feed, so the context starts cold on its first calculated bar like on TradingView.
request.currency_rate() accepts Pine v6's ignore_invalid_currency argument. A pair without rate data answers na either way.
A rate file whose bar length is unknown no longer hands out a bar's close at its own open: a legacy v1 file without a header period falls back to the period of its sibling .toml, and without any bar length the lookup answers na.
Security slicing keeps immutable scalars and pynecore helper calls out of alias classes, so a security child no longer keeps code its expression never reads (which could raise there, e.g. ta.rma with a zero length).
color
color.new and color.rgb clip an out-of-range transparency into 0-100 instead of raising, and round the alpha byte half up. color.t reads the transparency back as a whole number and gives 100 for a na color.
color.from_gradient mixes the endpoints with premultiplied alpha and truncates the channels; na endpoints, na values or bounds, equal bounds and reversed ranges follow TradingView.
Runtime and CLI
A script is imported by its exact file: a second script with the same file name no longer gets the first one's cached module and silently runs the wrong script.
Modules nested deeper than the default recursion limit transform correctly (a Pine switch with hundreds of arms compiles to an equally deep elif chain and failed with RecursionError).
timestamp() date strings accept a colon-less UTC offset (-0500).
Clearing stale error logs tolerates another process deleting them concurrently (shared workdir startup).
Performance
The AST transform pipeline is much faster: the passes use new walkers with per-class cached dispatch that skip childless nodes, and statement searches no longer enter expressions. Transform time over 912 real-world scripts drops by 35% (worst case 19.1 s to 11.9 s) and then by another 12% (worst case 11.4 s to 9.3 s). The emitted bytecode is unchanged.
request.security contexts at the chart's own symbol and timeframe that no other context consumes are served inline, without shared-memory signaling.
Documentation
Same-bar strategy.close() order behavior and the close_by_id option documented, with a strategy defaults table.
TradingView comparison figures refreshed (Pyne in the Wild: 930 scripts).