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
{{ message }}
Repository navigation
Commit f631685
Browse filesBrowse the repository at this point in the historyBrowse files
ta: bar-addressed extremum ring for conditional highest/lowest callers
TradingView keeps the source history of a window call site (ta.highest,
ta.lowest, ta.highestbars, ta.lowestbars) in a ring of K = length + 1
slots addressed by bar_index % K: a call on bar b writes slot[b % K] = src
and returns the extremum over the WRITTEN slots (b - k) % K, k in
[0, length). A call that executes every bar sees the plain positional
window (unchanged). A call that executes conditionally — inside an `if`
block that does not run every bar — keeps stale values in the slots it
did not rewrite, skips never-written slots, and is na iff
bar_index < length - 1, NOT until `length` executions have accumulated.
The engine's per-call deque was na until `length` pushes and never
dropped a value by bar distance: wrong from the second execution on.
Pins (2026-09-03, `lab tv`, NYSE:F 1D, 2025-04-01..2026-05-01):
if bar_index % 7 == 3: v = ta.highest(high, 5); size = round(v*100)
bars 3,10,17,24,31,38,45,52,59,66 -> na, 9.73, 10.10, 10.62, 10.78,
10.78, 10.78, 10.78, 10.78, 11.85 — 39/39 entry sizes exact;
cadence 9 (bars 3,12,21,...): na, 9.73, 10.32, 10.70, 10.70, 10.65,
10.87, 11.85 — 30/30 exact (call 6 = 10.65: a per-call buffer would
still answer 10.70). Production: colasbreugnon-sma F@1D 31/31 only with
K = 6; jayentriken BBWP ETH 358/364 stop exits.
Plumbing (no codegen change): ta::bar_context() is a thread-local
{installed, bar_index, origin}; ta::BarContextScope installs it RAII-
style. The engine installs the chart's Pine bar_index (origin =
bar_index_offset_, so a range-truncated feed still warms up over its own
first `length` bars) around on_bar, and the requested context's
evaluated-bar index (complete: eval_complete_count - 1, partial/
lookahead: eval_complete_count, calling-boundary replay: the index it
replays) around every evaluate_security dispatch — HTF aggregation,
lookahead partials, historical projections, lower-tf emulation/chunking
and the auxiliary feed all route through the new dispatch_security_eval.
With no context installed (unit tests, standalone use) every compute()
is its own bar: byte-identical to the deque.
Highest/Lowest/HighestBars/LowestBars share one ExtremeRing. Every-bar
callers are proven byte-identical to the previous deque (reproduced
verbatim in the test) over random series with and without na gaps, with
recompute() ticks, in no-context, chart and offset-origin modes. Ties
still resolve to the oldest member. The *Bars variants now record an na
input as a positional gap like Highest/Lowest (the deque skipped it
without advancing, so its offset pointed at the wrong bar); na in still
answers na out. ta.sma inside `if` (per-execution buffer) is untouched.
Tests: tests/test_ta_extremes_ring.cpp (cadence-7 and cadence-9 tapes
replayed bar by bar, na-until-bar-(length-1), lowest mirror, *Bars
offsets, every-bar identity, HTF-context sanity).
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dwbd239WT9zfcTLYM5UpUU
Claude-Session: https://claude.ai/code/session_01Jv3d6jrrCwdfxaZKV8MNTy
Copy file name to clipboardExpand all lines: docs/pine_v6_coverage_detail.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -790,14 +790,14 @@ All **✅ Runtime** — backed by `PineMatrix` (`matrix.hpp` / `matrix.cpp`) for
790
790
|`ta.dmi()`| fn | ✅ Runtime |`ta::DMI` class ||
791
791
|`ta.ema()`| fn | ✅ Runtime |`ta::EMA` class ||
792
792
|`ta.falling()`| fn | ✅ Runtime |`ta::Falling` class ||
793
-
|`ta.highest()`| fn | ✅ Runtime |`ta::Highest` class ||
794
-
|`ta.highestbars()`| fn | ✅ Runtime |`ta::HighestBars` class ||
793
+
|`ta.highest()`| fn | ✅ Runtime |`ta::Highest` class |bar-addressed ring (K = length + 1 slots by `bar_index`, per context — chart and each `request.security`): a call inside an `if` that does not run every bar keeps stale slots, skips never-written ones, na iff `bar_index < length - 1` (NYSE:F 1D pins 39/39, 30/30); every-bar callers unchanged |
794
+
|`ta.highestbars()`| fn | ✅ Runtime |`ta::HighestBars` class |same ring as `ta.highest`; offset = slot distance of the extremum |
795
795
|`ta.hma()`| fn | ✅ Runtime |`ta::HMA` class ||
796
796
|`ta.kc()`| fn | ✅ Runtime |`ta::KC` class ||
797
797
|`ta.kcw()`| fn | ✅ Runtime |`ta::KCW` class ||
798
798
|`ta.linreg()`| fn | ✅ Runtime |`ta::Linreg` class ||
799
-
|`ta.lowest()`| fn | ✅ Runtime |`ta::Lowest` class ||
800
-
|`ta.lowestbars()`| fn | ✅ Runtime |`ta::LowestBars` class ||
799
+
|`ta.lowest()`| fn | ✅ Runtime |`ta::Lowest` class |same bar-addressed ring as `ta.highest` (mirror) |
800
+
|`ta.lowestbars()`| fn | ✅ Runtime |`ta::LowestBars` class |same ring as `ta.lowest`; offset = slot distance of the extremum |
801
801
|`ta.macd()`| fn | ✅ Runtime |`ta::MACD` class ||
802
802
|`ta.max()`| fn | ✅ Runtime |`ta::AllTimeMax` class | Single-arg form only |
803
803
|`ta.median()`| fn | ✅ Runtime |`ta::Median` class ||
0 commit comments