Repository navigation
round 5: trail arming, OANDA day-stamp grids, daily session flags, TV affordability, extremes ring - #176
Merged
Conversation
Two trailing-exit rules diagnosed from TradingView tapes (TV is ground
truth). Family: winthetrade-ema-9-vwap-strategy-with-atr-trailing-stop
(strategy.exit("x", trail_points = atr*2, trail_offset = atr*2) -- a
price-unit ATR passed as TICKS) on 7 lanes: matchPct 100, entry/exit
timestamps exact, exit PRICE wrong on the same bar, so PnL / equity /
qty diverge from there.
(B) The bar's open is the first price a resting trail observes.
resolve_exit_path_fill only folded prices into the trail state AFTER
each O->L / O->H segment (update_exit_trail_state). With a POOC close
fill the carried best is the entry price itself (apply_market_order_fill
same_bar_close_fill guard), so a trail whose activation level the next
bar's open already sits past stayed dormant through an adverse-first
leg, armed only at the favourable extreme and filled at extreme -/+
offset. TV's emulator arms at the open with best = open and fills the
retrace at open -/+ offset.
OANDA:XAUUSD 15m long 2025-04-04 10:45Z @3110.31; 11:00Z bar
O 3110.40 H 3136.775 L 3109.24 C 3134.46, atr*2 ~ 15 ticks
(activation 3110.325, offset 0.015): TV "Long Exit" 3110.385 =
open - 0.015 (PnL 24.47); engine 3136.76 = high - 0.015 (PnL 8631).
194 of the 195 differing XAUUSD exits fit TV = open -/+ k ticks vs
engine = extreme -/+ the same k, always adverse-leg-first
(|O-L| < |H-O| for longs) with the open beyond the activation.
NASDAQ:AAPL 15m short 2025-04-02 18:45Z @222.93; 04-03 13:30Z bar
O 205.54 L 202.52: TV 205.55 (open + 1 tick), engine 202.53.
NYSE:F 1D long 2025-04-21 @9.47; 04-22 O 9.55 H 9.72: TV 9.54,
engine 9.71.
Fix: after try_exit_open_gap_fill declines (same liveness condition --
path cursor at the open, non-entry bar unless magnifier / cascade
waypoint), observe_exit_trail_open folds bar.open into the running best
and arms the trail iff the OPEN itself is past the activation. It never
arms from the carried best, so the #148 one-shot rule (an explicit zero
offset never retro-arms) is untouched; for exit-at-activation shapes an
open past the level was already gap-filled, so it is a pure best-price
observation there.
(A) A trail_offset in [0, 1) ticks is TV's explicit-zero one-shot trail.
compute_exit_trail_state gated the zero rule on trail_offset != 0.0 and
only then floored, so an offset in (0, 1) became a FINITE zero distance:
exits_at_activation = false and the stop rode exactly on the running
extreme, filling at the bar's best price. TV floors first and applies
the zero-offset rule: fill at the activation crossing, or at the open
when the bar opens past it, and no carried arming.
Pinned with `lab tv` on OANDA:EURUSD 15m (2025-04-01 -> 05-01): the
tapes for strategy.exit("x", "L", trail_points=3, trail_offset=0),
trail_offset=0.5 and trail_offset=0.9 are byte-identical
(190 rows, sha256 36aa80ac...).
EURUSD 15m short 2025-03-31 03:45Z @1.08330, atr*2 ~ 0.0006 "ticks"
(activation ceil -> 1 tick = 1.08329, floor(offset) = 0); exit bar
O 1.08330 L 1.08314: TV 1.08329 (the activation), engine 1.08314.
Fix: floor(trail_offset) first; a zero-tick result takes the existing
explicit-zero path (trail_offset_price NaN, one_shot_zero_offset_trail).
Whole-tick and larger fractional offsets keep the nils123456-orb /
legalrice floor rule unchanged; negative offsets are untouched. The
trail-peak fold in engine_fills.cpp already floors, so it agrees.
Tests: tests/test_trail_open_arm_subtick_offset.cpp (105 checks) pins
the XAUUSD / AAPL / F shapes at the resolver and, for XAUUSD and AAPL,
end to end through a POOC close-fill entry; 0 == 0.5 == 0.9 == 0.6 at
the activation, at a gapped open, and for the #148 no-retro-arm hold
(resolver and engine level, with the omitted-offset durable-arming
control); whole-tick 1.0 / 1.4 keep the floored trailing distance.
Against the pre-fix source 29 of those checks fail, all of them the
tape cells.
One existing pin contradicted the TV rule and is re-pinned, not
dropped: test_path_resolve_extra.cpp fl_sub (0f1f06e, a factorial
round, 2026-08-25) asserted that a 0.6-tick offset "rides the extreme
itself once armed (distinct from an explicit 0)" -- fill at the peak
102.00 -- as an extrapolation of the floor rule with no tape behind
the sub-tick cell. It now expects the activation 101.00 and equality
with the explicit-0 fill, with the `lab tv` evidence in the comment.
Every other trail pin (test_path_resolve_extra, the #148 retro-arm
cells, test_margin_call_trail_exit_chronology D, cascade G4) passes
unchanged. ctest 153/153 (was 152/152 before the new binary), scripts
unittest 102/102.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_014vizwdJMsDkHsjmS4StvZY
TradingView aligns the intraday request.security grid ("45", "240")
at the symbol's DAY STAMP -- the instant its daily bar starts -- and
on OANDA that instant is the 17:00 ET forex roll for every
instrument. EURUSD (1700-1700) opens on it, so its grid was already
right; XAUUSD (1800-1700) trades from one hour after it, and the
engine anchored its grid at the 18:00 ET session open
(intraday_clock_ms subtracting session_open_offset_minutes).
Pinned with `lab tv` on OANDA:XAUUSD 15, 2025-04-01..04-15
(pin-xau-grid-240 / -45 / -D: entry on ta.change(time("<tf>")),
close next bar, so every entry stamp is a boundary + 15 min):
"240": boundaries 01:00Z / 05:00Z / 09:00Z / 13:00Z / 17:00Z and
the day's first traded bar 22:00Z -- a 4h grid anchored at
21:00Z = 17:00 EDT, whose 17:00-21:00 ET bucket holds only
the 18:00-20:45 trading;
"45": boundaries 22:30Z / 23:15Z / 00:00Z / 00:45Z ... -- 21:00Z
+ k*45m (an 18:00 ET anchor puts them at 22:45Z / 23:30Z /
00:15Z);
"D": the daily bucket starts at the 17:00 ET stamp; the day's
first bar is 22:00Z.
Family evidence: all 7 TV base entries of every 3commas-* XAUUSD DCA
probe (request.security(syminfo.tickerid, "240", ta.rsi(...)) gate)
sit on the 17:00-ET 4h grid (21/01/05/09/13/17 ET) and all 7 engine
ones on an 18:00-ET grid; the 3 matched legs agree to 1e-6, so the
DCA math is exact once the grid agrees.
The rule lives in one place: session_day_stamp_offset_minutes
(src/timeframe.cpp) returns the session open for every session
except the 1800-1700 window, whose stamp is its 17:00 close -- the
same hour engine_aux_security.cpp already routes OANDA's native
daily bars by. intraday_clock_ms subtracts the stamp instead of the
open, so the request.security ratio buckets, bucket_open_ms /
bar_label_ms (the grid label, finding 473), tf_change and the
range-start bucket cut all move together. The session-day ordinal
runs on the same clock; since no 1800-1700 bar trades in the
17:00-18:00 hour the two clocks attribute differently, every D/W/M
anchor of that session is unchanged: the D bar opens 18:00 ET and
closes 17:00 ET, the week opens Sunday 18:00 ET, and OANDA's
17:00-ET-stamped daily bars still route to the session they cover
(session_covered_instant_ms now rolls a pre-open stamp forward to
its session's open, keeping its documented contract bit-for-bit).
One consequence is a fix of its own: the "D" bucket on 1800-1700
now completes on the session's last chart bar (16:45 ET, whose
close is the stamp) as it does on 1700-1700, instead of on the next
session's first bar.
Sessions whose open is the stamp keep their grid bit-for-bit: OANDA
1700-1700 (now the very grid XAUUSD uses), CME 1700-1600 CT, NYSE
0930-1600, NSE 0915-1530, 24x7 UTC. tests/test_oanda_day_stamp_grid
pins the XAUUSD "240" / "45" grids in EDT and EST, the unchanged
session-day model and D completion, and those regression grids;
compiled against the previous library its XAUUSD checks fail and
every regression pin passes.
Not touched, reported as follow-ups: time("<intraday tf>")
(session_time.cpp compute_tf_open_ms) still keys intraday tfs on the
UTC epoch grid for every symbol -- the pin strategies would expose
that separately -- and time("D") on 1800-1700 still reports the
18:00 ET session open.
ctest 153/153 (152 + the new binary, 683 checks); scripts unittest
102 OK; check_c_abi_runtime.py clean.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_014vizwdJMsDkHsjmS4StvZY
Claude-Session: https://claude.ai/code/session_01BvPydDgRoDYDWrjz5JtGE1
TradingView's rule for the session.is* market-state variables on a chart bar: on "1D" and above session.ismarket is true on every bar and session.ispremarket / session.ispostmarket are false — a daily bar covers whole session days, not a time of day. Intraday charts keep the time-of-day test byte for byte. On such a chart the bar is its whole session, so session.isfirstbar and session.islastbar both equal session.ismarket there. Evidence: roi10x-shiva-lt-ls-blend on OANDA:XAUUSD @1d. The symbol's session is 1800-1700 America/New_York and its daily bars are stamped at the 17:00 ET break (minute 1020, outside the wrapped window [1080, 1020)), so the time-of-day test never held; every signal is ANDed with session.ismarket, and the engine took 0 trades against TradingView's 57. - session_time: chart-timeframe forms of pine_session_ismarket / ispremarket / ispostmarket (fourth argument chart_tf) that apply the daily rule and otherwise defer to the three-argument forms; tf_is_daily_or_higher in timeframe.hpp. - engine: BacktestEngine members of the same name wrap them with the script timeframe. Codegen lowers the variables to the unqualified call pine_session_is*(syminfo_.session, syminfo_.timezone, current_bar_.timestamp) inside the generated class, so class-scope lookup resolves to these members and the emitted code is unchanged. The streaming clock's tick-less-interval skip keeps the raw time-of-day form, qualified explicitly. - the bar pumps (simple, aggregation, magnifier, stream) set the per-bar predicates through set_session_bar_state, which applies the daily-chart first/last rule. - tests/test_session_predicates_daily_chart pins the XAUUSD tape on a 1D feed (cloud-caller shape, explicit "1D", single-timeframe run), the same session on a 15m feed unchanged, 0930-1600 on a 1D feed, a daily chart aggregated from 60m, the stream's realtime daily bar, and the chart-timeframe forms directly. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01TMHfywLQuXUYNxD2ZbWABd
TradingView keys time("<intraday tf>") / time_close on the symbol's
DAY-STAMP-anchored HTF grid -- the grid 88cd0c8 gave request.security's
ratio buckets -- on every session symbol, and on the epoch grid only
where the stamp is 00:00 UTC; time("D") on OANDA's 1800-1700 session
is the 17:00 ET stamp the D bar opens on, not the 18:00 ET session
open, and time_close("D") the next stamp.
Pinned with `lab tv` (pin-time-hours: strategy.entry(qty =
hour(time(tf), "America/New_York") * 100 + minute(...) + 10000 /
20000 / 30000 for "D" / "240" / "60"), 15m charts, 2025-04-01..07-01):
OANDA:XAUUSD 1800-1700 ET: "D" = 17:00 on 147/147 entries (the
engine reported 18:00); "240" in {01:00, 05:00, 09:00, 13:00,
17:00, 21:00}; "60" every hour on the hour except 17:00;
NYSE:F 0930-1600 ET: "D" = 09:30; "60" in {09:30, 10:30, .., 15:30}
-- session-anchored, not the epoch hour the engine reported;
"240" in {09:30, 13:30};
NSE:NIFTY 0915-1530 IST: "D" = 23:45 NY (09:15 IST); "240" in
{23:45, 03:45} NY (09:15 / 13:15 IST);
BINANCE:BTCUSDT 24x7 UTC: "D" = 20:00 NY (00:00 UTC), epoch grid.
CME_MINI:ES1! exported 0 rows: its request.security "240" grid (17:00
CT anchored) is pinned unchanged and time("240") reads it.
One grid, one place: session_intraday_bucket_open_ms (timeframe.cpp)
is the RATIO bucket of TimeframeAggregator::bucket_open_ms and the
intraday path of compute_tf_open_ms (session_time.cpp), which now
takes the symbol's tz/session from the seven-argument pine_time /
pine_time_close forms; the five-argument forms pass UTC / "" and stay
on the epoch grid bit-for-bit. session_period_open_ms opens the D/W/M
bar on its first session-day's stamp (session_day_stamp_real_ms) and
W/M close on the next period's stamp; the DAY close (open + length =
the next stamp) and session_day_open_real_ms -- the trading open that
session_covered_instant_ms and the close arithmetic use -- are
unchanged. The aux daily-bar router keys both sides through
session_period_open_ms, so its keys move together; the range-start
bucket cut now keys the 1800-1700 D bucket on the stamp, which is
where TradingView's D bar opens. Every session whose open is its
stamp (OANDA 1700-1700, CME 1700-1600 CT, NYSE, NSE, 24x7) is
bit-identical for D/W/M; their intraday time(tf) moves from the epoch
grid to the session grid, as the tapes read.
Re-pins, disclosed:
- tests/test_session_day_anchors "Intraday tfs keep the epoch grid"
arrived with b1449c3 (factorial: engine-symbol-r5, #162) as a
design statement with no tape behind it; its "60" check on
OANDA:EURUSD 1700-1700 never told the grids apart (17:00 ET is on
the hour) and still holds; "240" is now pinned to the 17:00-ET
grid.
- tests/test_session_day_anchors "CME-style 1800-1700" (b1449c3, a
session-length parser edge case written in the New York zone) is
OANDA's metals session: its D / W open re-pinned to the stamp, the
close unchanged. A real CME session (1700-1600 Chicago) is pinned
with open == stamp.
- tests/test_oanda_day_stamp_grid rule D (88cd0c8's design pin: the
1800-1700 D/W/M open and D label at the 18:00 session open) now
reads the 17:00 stamp; the W/M open follows the D bar (the same
relation 1700-1700 has) -- extrapolated, no W/M tape.
tests/test_pine_time_day_stamp_grid pins the four tapes and the CME
regression grid (92 checks). ctest 154/154 (153 + the new binary;
test_oanda_day_stamp_grid 692, test_session_day_anchors 23853);
scripts unittest 102 OK; check_c_abi_runtime.py clean. Against the
previous library 53 / 18 / 4 of those checks fail respectively.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dwbd239WT9zfcTLYM5UpUU
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
The CME grid is no longer an extrapolation: pin-time-hours-cme (`lab tv`
on CME_MINI:ES1! and NQ1! 15, 2025-04-01..07-01, capital 1e14 so every
entry is affordable; Size = HHMM New York of time(tf) + 10000 / 20000 /
30000 for "D" / "240" / "60") reads
"D" = 18:00 NY (17:00 CT) on 147/147 entries of each symbol,
"240" in {18:00, 22:00, 02:00, 06:00, 10:00, 14:00} NY
(17:00 / 21:00 / 01:00 / 05:00 / 09:00 / 13:00 CT),
"60" every hour on the hour except 17:00 NY (the 16:00-17:00 CT
break) --
the 17:00-CT session-open grid request.security already used and
72ae4f1 routed time() through. tests/test_pine_time_day_stamp_grid rule
E now walks every session of the tapes' range (66 evening opens, 92 bars
each) against those Size sets, pins the D close at 16:00 CT and the
five-argument (epoch) contrast, alongside the unchanged
request.security bucket pins.
ctest 154/154 (test_pine_time_day_stamp_grid 100 checks); scripts
unittest 102 OK; check_c_abi_runtime.py clean.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dwbd239WT9zfcTLYM5UpUU
design-market-entry-affordability. A MARKET strategy.entry is admitted iff
lot_floored(resulting_position_qty)
* max(tick(close(S)), tick(fill)) * pv * fx * margin/100
<= placement_equity + max(1e-9, |placement_equity| * 1e-12)
evaluated twice: at placement on tick(close(S)) against mark-to-market
equity (initial + net_profit + open_profit at close(S)), and again at fill
on tick(fill) against the same placement snapshot. "Resulting position" is
the new side's qty on a reversal (the closing leg is not costed) and
held + add on a same-direction add, with "held" frozen at placement: a
same-source-bar sibling that fills first is not re-costed at the later
order's fill (the thula INR non-POOC short pair's TV rows, pinned in
test_margin_call, fill both 2-lot shorts from flat and margin-call the
over-notional 4-lot position 2.6088 rather than declining the second).
Commission is not in the notional and
there is no max(equity, signal_notional) admission floor. A rejected
reversal drops the ENTRY leg only: the order survives as a close-only
transaction (PendingOrder::affordability_close_only) and its closing leg
still executes at the fill under the entry's id. A rejected flat open or
add is dropped (no trade row, no intraday-cap slot).
Scope: explicit-qty entries and default FIXED / CASH sizing. Default
percent_of_equity keeps its pinned KI-54 / gap-reject / gross-admission
family unchanged (its reversal decline is atomic and holds the position —
not provably the same rule). The KI-65 explicit MARKET/MARKET pair keeps
its own frozen gross-transaction admission (including its signal-notional
floor). Slippage ticks are in neither price basis (the pins are all at
slippage 0; the rule is stated on the rounded bar prices).
Before this change FIXED/CASH default entries had no affordability check
at all (rampatel BTC 2025-05-12 07:15Z: the engine opened a long TV had
refused, margin-called 4x the shortfall and cascaded to 23,605 trades vs
TV's 1,486), and the explicit-qty gate costed the RAW qty against
realized-only equity at placement and admitted through a
max(equity, signal_notional) floor at fill.
Pins (lab tv, 2026-09-03; scratchpad/r5/pins):
pin-afford-flat / -reverse CME_MINI:NQ1! 15, fixed qty 1, margin 100:
10,212 flat-entry + reversal decisions, 0 mismatches; 2025-05-06
14:15Z short reversal filled with realized 396,625 < cost 397,995
because MTM 398,455 >= cost.
pin-afford-gapup capital 380,000: close 18,820.50 (376,410) admitted,
fill 19,225 (384,500) -> not filled.
pin-afford-gapdown capital 345,000: close 17,483.25 (349,665) rejected
at placement although the 17,100 fill (342,000) fit.
pin-afford-gapup-ctl capital 1e6 fills at 19,225.
pin-admit-allin-xau OANDA:XAUUSD 15, qty = strategy.equity/close, comm
0.05%, 1279/1279: 2025-04-08 13:30Z E 1,998,000.02,
close 3013.72, open 3013.745, lot 0.01 -> 662.968 ->
662.96 admitted (the raw 662.968 * 3013.745 > E).
pin-admit-allin-f NYSE:F 15, 352/352: half-cent close 10.225 -> fill
10.23, floor(E/10.225) * 10.23 > E -> declined.
masayanfx NQ1 2025-07-30 20:15Z: add 2 * 23,667.75 * 20 = 946,710 > MTM
945,225 -> TV dropped the add.
Tests: tests/test_market_entry_affordability.cpp (new, 68 checks): the NQ
gap-up / gap-down / control shapes, favorable gap, exact tie, margin
scaling, the MTM reversal, a reversal declined at fill (close leg only),
the rampatel shape with and without margin calls, a co-queued close after
a declined reversal, default and explicit pyramiding adds costed as
held + add, XAUUSD 662.96, the F half-cent decline, CASH sizing, POOC.
Re-pinned (disclosed; each fixture encoded engine scope, not a TV tape):
test_explicit_qty_fill_admission GREEN-H -> H: same-bar close-then-
reentry on an adverse gap is now DECLINED (no after-close carve-out).
test_margin_admission_gate F: CASH 20k on 10k capital at margin 100 is
DECLINED (was "exempt, must fill"); cash 5k control fills.
test_margin_call: the unequal-fill short add (placed while holding the
base) is DECLINED at placement instead of admitted-then-4x-trimmed; the
gapped 10-lot reversal (10 * 120 > 1,000) keeps only its closing leg
(no long, no nibble); the same-bar explicit pair fixture now runs the
real POOC flow (no forced fill between the two placements) and keeps
its original admit-then-trim rows; the commissioned default-short
AcceptedAdd mutation is placed once the short is in profit.
test_direct_short_reversal_affordability: the AcceptedAdd mutation is
placed once the all-in short is in profit (affordable as held + add).
test_close_id_retires_ledger C: bar3 closes at 79 so the M add is
affordable; ledger assertions unchanged.
test_short_seed_close_collision RejectedExtraCall: the rejected extra
call is a same-direction add (a rejected reversal now queues a close-
only order, so it is no longer invisible).
ctest: 153/153 (test_market_entry_affordability 68/68, test_margin_call 457/457); scripts python unittest: 102/102.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dwbd239WT9zfcTLYM5UpUU
…ring
TradingView reads the bar-addressed ring through a cached extremum: each
site keeps {value, implied bar}. On a call at bar b: write slot[b % K];
first call caches (src, b); a src that strictly beats the cache takes it
without reading the slots, aged-out cache or not; otherwise, once the
cached extremum has aged `length` bars (by bars, not calls) the slots are
rescanned oldest-first (aliasing included) and re-cached as
(best, b - k_best); otherwise the cache is kept and the aliased stale slots
stay unread. Ties never displace the cache outside the scan; na src never
updates it; a recompute() on the cache's bar restores the pre-bar cache and
re-applies. Every-bar callers are byte-identical to the positional deque.
Pinned 2026-09-04 with lab tv: six NYSE:F 1D aliasing tapes (runs with
gaps, literal and input.int lengths identical) 625/625 entries, both
cadence tapes, the BINANCE:ETHUSDT.P 15 geometry pin (82/82) and the
jayentriken-bbwp-macd-ema-trend-strategy ETH replay 593/593 stop exits
(plain ring 587, per-call deque 544). t382: bars 48..51 keep the cached
9.88 over bar 3's aliased 9.20, bar 52 rescans to 9.20; ETH bar 4990's own
low 2648.62 beats the expired cache 2650.47 and never reads the aliased
08:15 slot. Never-written slots stay skipped (TradingView's deep-backtest
export reads them as 0, but the campaign grades against UI-scraped tapes
whose chart carried pre-range writes).
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dwbd239WT9zfcTLYM5UpUU
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.
Round-5 engine candidate — every rule pinned with
lab tvsynthetic probes before coding (ledger: "Round 5 pins"), measured like-for-like on Cloud Run against the round-5 harness pin.trail_offsetis an explicit zero (EURUSD tapes for 0/0.5/0.9 byte-identical). winthetrade on 7 lanes.time(tf)/time("D")anchor at the 17:00 ET day stamp (pinned on XAUUSD/F/NIFTY/BTC/ES/NQ); CME/NYSE/NSE grids unchanged and pinned.Measured (with pineforge-codegen-oss round5/hoist-lazy-rhs-ta): +138 / −2 tiers vs the like-for-like pin, excellent+strong 96.0% → 97.8%.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Dwbd239WT9zfcTLYM5UpUU