- src/NT8.Strategies/Examples/SimpleORBStrategy.cs: publish side-specific trend confirmation values - src/NT8.Core/Intelligence/FactorCalculators.cs: score trend confirmation by intent side - tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs: add long/short symmetry coverage - SPRINT_BOARD.md: GAP-062 prompted -> implemented - docs/00-governance/current_status.md: updated GAP-062 status - docs/00-governance/decisions.md: recorded DEC-20260826-01 - TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md: committed task prompt Build: clean | Tests: 569 passing | Dual-deployed: yes, backup 20260826_005308
9.6 KiB
TASK: GAP-062 — trend_confirm is direction-blind, capping every short's Trend factor
Staged: 2026-08-26 (trade-frequency investigation, DEC-20260825-04; confirmed provable-
from-source in GAP-061's own commit writeback)
Sprint: Stage 1 — real scoring-behaviour change (see VALIDATION — this is NOT
behaviour-neutral, unlike GAP-050/GAP-061)
Owner: Kilocode
Deploy: COMMIT ONLY — do NOT run deploy-to-nt8.bat or copy build output to
the live NT8 install as part of this task. Verify-build and commit
as usual; leave the deploy step for the operator to run manually
once ready.
─────────────────────────────────────────────────────────────────
THE DEFECT
TrendAlignmentFactorCalculator.Calculate()
(src/NT8.Core/Intelligence/FactorCalculators.cs ~116-186) scores the Trend
confluence factor additively out of three components:
+0.4if price is on the trade's side of AVWAP.+0.3ifavwapSlope's sign agrees with the trade direction (slopeAligned).+0.3iftrend_confirm > 0.5.
trend_confirm is computed once per bar in
SimpleORBStrategy.UpdateConfluenceInputs()
(src/NT8.Strategies/Examples/SimpleORBStrategy.cs:970):
context.CustomData["trend_confirm"] = avwapSlope > 0.0 ? 1.0 : 0.0;
This is direction-blind — it unconditionally rewards a positive slope,
regardless of which way the candidate trade is going. For a Sell/short
trade, slopeAligned requires avwapSlope < 0.0. These two conditions
(avwapSlope < 0 for slopeAligned, avwapSlope > 0 for trend_confirm)
are mutually exclusive by construction: a short trade can never earn both
the +0.3 slope-aligned bonus and the +0.3 trend-confirm bonus, even when
the trend is cleanly and correctly bearish. The maximum Trend score a
short with a genuinely confirmed downtrend can reach is 0.3 (or 0.7 if
price is also below AVWAP) — structurally capped below what a long in an
equally clean uptrend can reach (1.0).
This is not a hypothesis. It was first identified while drafting GAP-061
(DEC-20260825-04 addendum), then independently re-confirmed by Kilocode's
own commit writeback for GAP-061 (DEC-20260825-04/DEC-20260825-05) after
a fresh read of the same source. It also matches real log data exactly:
every best real short setup on both 2026-08-18 and this week scored
Trend=0.30 — never higher, regardless of how clean the actual downtrend
looked. With MinTradeGrade=A, this has been silently vetoing every
well-formed short setup this system produces.
READ-FIRST
DEC-20260825-04indocs/00-governance/decisions.md— full investigation trail, including the addendum where this was first found and the addendum from GAP-061's own commit re-confirming it.DEC-20260825-05— Claude's verification of the GAP-061 commit, including the note that Kilocode's own re-read independently confirmed this finding before implementing GAP-061's telemetry-only scope.src/NT8.Core/Intelligence/FactorCalculators.cs~116-186 —TrendAlignmentFactorCalculator.Calculate(). Confirm the additive logic and theslopeAligned/trend_confirmmutual exclusivity for shorts is still accurate before changing anything.src/NT8.Strategies/Examples/SimpleORBStrategy.cs~926-975 —UpdateConfluenceInputs(), wheretrend_confirmis computed and written tocontext.CustomDataevery bar. Confirm what direction information is already available at this point (the candidate trade side, if any, or whatever proxy for "which way are we about to trade" this method has access to — read the surrounding lines to confirm exactly what's in scope here before designing the fix).src/NT8.Adapters/Strategies/SimpleORBNT8.cs~356-370 (post-GAP-061) —GetStateTelemetryContextFields()now surfacesAvwap/AvwapSlope/TrendConfirmraw values inSTATE_CONTEXT. If deployed and observed before this task starts, realAvwapSlopevalues from live/SIMSTATE_CONTEXT:lines are additional evidence worth checking against — note in your writeback whether any such log data was available and what it showed, but do not block on it; the source-level proof above stands on its own.tests/NT8.Core.Tests/Intelligence/— existing tests forTrendAlignmentFactorCalculator(find by class name), to understand the current expected-score fixtures you'll need to update.
THE CHANGE
Make trend_confirm direction-aware: it should reward genuine trend
confirmation in the direction of the candidate trade, not merely "slope is
positive."
The exact mechanism is your call, but it must satisfy all of the following:
- Symmetry: a long in a confirmed uptrend and a short in a confirmed
downtrend must be able to earn the same maximum Trend score (i.e.
trend_confirm > 0.5must be achievable for both directions when the underlying trend genuinely supports that direction). - No new inputs invented: use
avwapSlope(already computed) and whatever direction signalUpdateConfluenceInputs()already has access to (read THE READ-FIRST #4 first — do not thread new parameters through the call chain if the direction is already derivable at that point; if it genuinely isn't available yet atUpdateConfluenceInputs()time, explain why in your writeback and propose the minimal way to get it there). - Do not change the additive structure or weights of
TrendAlignmentFactorCalculator.Calculate()(+0.4/+0.3/+0.3) — only fix whattrend_confirmmeasures. This task is about correcting the input, not redesigning the scoring formula. - Do not weaken long-side behavior. A long trade's existing
trend_confirmvalue for a positive-slope uptrend must remain1.0after this change (verify this explicitly in your tests) — the fix should only correct the short-side blind spot, not change long scoring.
A reasonable shape (illustrative, not prescriptive — use your own judgment
after reading the surrounding code): instead of a single unconditional
avwapSlope > 0.0 ? 1.0 : 0.0, compute trend_confirm per-side (e.g. by
storing both a long-confirm and short-confirm value, or by deferring the
comparison until the candidate trade's side is known at scoring time) so
that TrendAlignmentFactorCalculator reads the correct one for the
direction actually being evaluated.
DO NOT
- Do not change the
+0.4/+0.3/+0.3weights or the additive structure inTrendAlignmentFactorCalculator.Calculate(). - Do not change how the
+0.4price-vs-AVWAP or+0.3slopeAlignedcomponents are computed — onlytrend_confirm. - Do not change
MinTradeGrade,GradeFilter,ConfluenceScorer's other 9 factor calculators, or any risk/order-flow/sizing code. - Do not change the
STATE:/STATE_DETAIL:/STATE_CONTEXT:log line formats (GAP-061's telemetry fields already surfaceTrendConfirm— this task changes what value gets computed, not how it's logged). - Do not touch
RegimeVeto, the AVWAP hard veto for longs, orEnableShortTrendFilter— separate mechanisms, out of scope.
TESTS (required)
- A test proving a short candidate trade in a confirmed downtrend
(
avwapSlope < 0, direction-consistent) now earnstrend_confirm > 0.5and reaches the same maximum Trend score a symmetric long would reach in a confirmed uptrend. - A test proving a short candidate trade against the trend
(
avwapSlope > 0, i.e. price trending up while evaluating a short) correctly does NOT earntrend_confirm > 0.5— the fix must not become directionless in the other direction (always-true would be as wrong as the current always-check-positive-slope bug). - A test proving long-side behavior is byte-identical to before this
change: a long in a confirmed uptrend still scores
trend_confirm = 1.0as it did previously. - Update (do not just add alongside) any existing
TrendAlignmentFactorCalculator/UpdateConfluenceInputstest fixtures whose expected values assumed the old direction-blind formula — find them via the existing test files identified in READ-FIRST #6. - Confirm the full existing suite still passes.
VALIDATION (operator)
Unlike GAP-050/GAP-061, this IS a real trading-behaviour change — it
will change actual trade eligibility. Previously B/C-Grade-capped short
setups can now legitimately reach Grade A (and pass MinTradeGrade), which
means this fix can cause the strategy to start taking short trades it
previously silently rejected. Before deploying to SIM:
- Confirm the build/tests pass per above.
- Do NOT deploy automatically — the operator will manually build, deploy, and run this on SIM to observe: does at least one short setup that was previously capped at Grade B/C now score Grade A on a comparable confirmed-downtrend setup? Does long-side Grade distribution look unchanged versus before?
- Flag explicitly in your writeback that this is a scoring-behavior change requiring SIM observation before/after, not a "none required" item like the last two tasks.
GOVERNANCE
Track as [GAP-062] in SPRINT_BOARD.md. Update
docs/00-governance/decisions.md with a new dated entry (next available
number after DEC-20260825-05) recording the implementation and explicitly
restating the symmetry proof from TESTS #1-#3 above so the operator has a
clean, test-verified basis for trusting the fix before running it live.
Reference: this task, DEC-20260825-04, DEC-20260825-05,
TASK_GAP061_AVWAP_TELEMETRY_PROMPT.md (the investigation this follows
from).