codegen: chart-context ta.atr / ta.tr pass the previous CHART bar's close to compute() (issue #178) - #124
Merged
Merged
Conversation
…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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Composite with engine PR pineforge-engine
round10/candidate-q(00e3a52): a sparse (conditional)ta.atr/ta.trcall 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_CLOSEappendsprev_chart_close()in the chart context; the precalc pre-pass usesbars[i-1].close; request.security keeps the 3-arg form. Gatepineforge-pr-gate-2mk9gPASS (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