Skip to content

v6.16.2

Latest

Choose a tag to compare

@wallneradam wallneradam released this 04 Dec 09:17

Strategy engine: more order combinations match TradingView

  • A strategy.close(id) called before strategy.entry on the same bar now frees that id's pyramiding slots for the entry, as on TradingView. A close called after the entry frees nothing. On the "20 years old Turtles strategy" reference (BINANCE:BTCUSDT 30m, pyramiding=5), 5574 of 5576 trades match, up from 27 missing and 23 extra entries.
  • A strategy.close() sized from two or more open entries is dropped once every one of them is spent before the close fills (by a reversal or a strategy.order). A close sized from a single entry still closes whatever is open under its id. With this fix the Turtles reference matches all 5574 of its closed trades.
  • A strategy.close() / strategy.close_all() market order no longer dies when an earlier order of the same batch closes its position. At its turn it closes whatever opposite position it finds, oldest-first and clamped to that position. It dies only on a flat or same-side position. The pyramiding gate and the price-entry flip apply the same rule, so an entry placed after an order that flattens the position is no longer rejected as a pyramid add.
  • A two-level exit that gaps through one of its levels at the bar open is now filled in the queue of the level the gap triggered, as TradingView fills it.
  • strategy.risk.max_drawdown is now checked when a closing fill books, with equity marked at the fill price. The rest of the position closes at the next node of the bar's assumed path. Before, the rule was checked after the bar against the bar close, and the forced close filled at the close. This also applies on the bar magnifier path.
  • A closed trade's cumulative profit is now the netprofit at its exit fill, including the entry commission of trades still open at that moment, as in TradingView's trade list.

ta builtins

  • ta.highest, ta.lowest, ta.highestbars and ta.lowestbars follow TradingView's current window behavior, measured on BINANCE:BTCUSDT 30m and 1D. Each call site keeps the non-na values it received, one per chart bar. An na call keeps the current window. The window is the last length entries whatever the qualifier of length. The bars form points at the newest bar holding the extreme. The result is na until bar_index reaches length - 1. One implementation now serves every call: conditional, na-source, loop and varying-length calls all match the probes from bar 0. ta.linreg is unchanged.
  • ta.ema at length 1 now runs its step like TradingView, which rounds a source much smaller than the previous value.
  • ta.rma, ta.dev, ta.linreg, ta.median and ta.wpr run their full computation at length 1. TradingView takes no shortcut there, so a few edge values change: rma turns -0.0 into +0.0, dev is na on an na bar, linreg over a single point is na, median returns the last non-na value on an na bar, and wpr returns 100 * (close - high) / (high - low).
  • The default ta.vwap anchor is now timeframe.change("1D"), so it also resets on the first bar and on the first bar of a trading day whose opening bars are missing.

Matrix

  • matrix.inv() and matrix.pinv() match TradingView on large matrices (measured up to 120x120). A square matrix whose LU pivot product is exactly zero is now treated as singular: inv() raises a runtime error, and pinv() goes through the SVD. An overflowed or subnormal determinant is not treated as singular. The SVD pseudoinverse sums each cell in blocks of 52 terms when V holds more than 4096 cells, as TradingView does.
  • New compiled extension core/_native_matrix, included in the platform wheels. It is a bit-identical twin of the LU inverse, the pseudoinverses and the eigen decomposition, and the Python code stays as the reference and fallback. PYNE_NO_NATIVE_MATRIX turns it off. mult(), kron(), det() and rank() get a compiled fast path when every cell is a float.

Live broker fix

  • One-way emulator: a close the venue reports as executed no longer holds its leg back forever. On a venue that reuses the leg id for the next position of a side (Bybit hedge positionIdx), every later close of that side could dispatch nothing. A venue-settled send now holds the leg for at most 120 s after it went out.

Documentation

  • The docs now state Pine Script v1 to v6 support. v1 to v3 are no longer described as best-effort, and a source without a //@version line is read as v1.
  • The TradingView validation snapshot is updated to 2026-12-04: 1,094 published scripts (Pine Script v1 to v6), all 1,479 comparable outputs matching, 99.957% of 148 million plotted values bit-identical, and 420,443 strategy trades.