Skip to content

codegen: chart-context ta.atr / ta.tr pass the previous CHART bar's close to compute() (issue #178) - #124

Merged
luisleo526 merged 1 commit into
mainfrom
round9/issue178-codegen
Sep 5, 2026
Merged

codegen: chart-context ta.atr / ta.tr pass the previous CHART bar's close to compute() (issue #178)#124
luisleo526 merged 1 commit into
mainfrom
round9/issue178-codegen

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

Composite with engine PR pineforge-engine round10/candidate-q (00e3a52): a sparse (conditional) ta.atr/ta.tr call site read the previous EXECUTION's close for its true range; TradingView reads the chart's close[1] on every execution (sensor tape 398/398, reporter's shape 374/393, JOAT aureate byte-identical with the engine's checkpoint rollback). TA_CHART_PREV_CLOSE appends prev_chart_close() in the chart context; the precalc pre-pass uses bars[i-1].close; request.security keeps the 3-arg form. Gate pineforge-pr-gate-2mk9g PASS (score +27, hard 0), recorded for engine 00e3a52 / codegen 3fd97fe. Fast-forward merge; lab promote --composite.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MNfDxwjexZsvasfjZ1kDt4

…lose to compute() (issue #178)

TradingView (pinned 2026-09-06, lab tv i178-sparse-atr-sense, BINANCE:BTCUSDT
60): a ta.atr call site inside a block that does not execute every bar
advances its RMA on the executions only, but reads its true range against
close[1] of the chart (398/398), never the close of the site's previous
execution (0/398). The engine's per-object prev_close was that refuted
model; engine branch issues/178-sparse-atr-prev-close adds
ATR/TR::compute(high, low, close, prev_chart_close) and the always-on
BacktestEngine::prev_chart_close() tracker.

- tables.py: TA_CHART_PREV_CLOSE = {atr, tr}, TA_CHART_PREV_CLOSE_ARG.
- ta.py _ta_compute_args_for_site: chart-context atr / tr append
  prev_chart_close(); the request.security path (bar. rewrite) keeps the
  3-arg form.
- emit_top.py precalc pre-pass: the pre-pass walks bars[i] itself, so the
  argument becomes (i > 0 ? bars[i - 1].close : na<double>()).
- tests: test_sparse_atr_prev_close.py (chart / precalc / security
  contexts); the two tr compute-string assertions updated. Suite green.

Requires the engine branch above (older engines lack prev_chart_close()).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JSnCbsooVNcngFakUpMMzu
(cherry picked from commit 048777d)
@luisleo526
luisleo526 merged commit 3fd97fe into main Sep 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant