Skip to content

Match TV's na-source output rules for ta.ema and ta.sma#93

Merged
luisleo526 merged 1 commit into
mainfrom
fix/ta-na-source-rules
Jul 11, 2026
Merged

Match TV's na-source output rules for ta.ema and ta.sma#93
luisleo526 merged 1 commit into
mainfrom
fix/ta-na-source-rules

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

What

Over a conditionally-na source (cond ? x : na), TV pins different output rules per function with identical state rules (na never updates, never resets):

  • ta.ema returns na on the na-input bar, resuming the recursion over valid inputs — the engine's existing RMA pattern. The engine returned the held value.
  • ta.sma returns the held compact-window mean once seeded, persisting through 32+-bar na runs. The engine returned na.

Pinned by a committed clean-room probe: the winning hypotheses scored 0/11,060 mismatched decision bars per leg; each competing rule (hold-and-ignore, re-seed, na-propagate, count-na-in-length) was refuted by thousands of bars. Return paths only; RMA/WMA/VWMA, state mutation, and seed conventions untouched. SMA's intra-bar security recompute keeps its old na return (undiscriminated — documented asymmetry pending its own pin).

Gates (author + independent fresh-context R7, both green)

  • REDs by stash-cycle: 28/34 pre-fix → 62/62 post; one legacy assertion pinning the old EMA behavior flipped to the TV rule (assertion-level, body preserved); full ctest 91/91.
  • Corpus 252/252 — 240/11/1, zero movement (plain sources never feed na).
  • End-to-end: the probe converges 3,656/3,658 (px 100%); the exemplar strategy improves canonical 95.8→99.0, coverage +9pp, exit p90 79× better; KI-55 na-warmup beneficiary byte-identical.
  • Private validation sweeps: targeted 14/14 and full 412 both 0 up / 0 down, inventory stable.

🤖 Generated with Claude Code

TradingView pins different OUTPUT rules per function over a
conditionally-na source, with identical state rules (na input never
updates and never resets state): ta.ema RETURNS NA on the na-input bar
and resumes the recursion over valid inputs — the same pattern this
engine already implements for RMA — while ta.sma returns the HELD
compact-window mean on every bar once N valid values have been seen,
persisting through arbitrarily long na runs. The engine had both
backwards: EMA returned the held value on na bars, SMA returned na.

Pinned by a clean-room probe (committed with its TV export) whose
winning hypotheses scored zero mismatches on all 11,060 decision bars
per leg; the four competing na rules were each refuted by thousands of
mismatched bars. Return paths only — state mutation, RMA/WMA/VWMA, and
seed conventions untouched. SMA's intra-bar security recompute path
keeps its old na return (undiscriminated by the probe; documented
asymmetry pending its own pin). One legacy assertion that pinned the
old EMA held-output behavior is flipped to the TV rule.

Exemplar: the na-gated cloud strategy improves canonical match
95.8→99.0, coverage 81.7→90.7, exit p90 0.0947→0.0012; the probe
converges 3656/3658; corpus 240/11/1 zero movement; full private sweep
0 up / 0 down.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@luisleo526 luisleo526 merged commit a71f259 into main Jul 11, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/ta-na-source-rules branch July 11, 2026 09:33
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