Files
nt8-sdk/TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md
mo 885e298fb7 [GAP-062]: trend confirm direction fix complete
- 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
2026-08-26 00:53:32 -04:00

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.4 if price is on the trade's side of AVWAP.
  • +0.3 if avwapSlope's sign agrees with the trade direction (slopeAligned).
  • +0.3 if trend_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

  1. DEC-20260825-04 in docs/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.
  2. 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.
  3. src/NT8.Core/Intelligence/FactorCalculators.cs ~116-186 — TrendAlignmentFactorCalculator.Calculate(). Confirm the additive logic and the slopeAligned/trend_confirm mutual exclusivity for shorts is still accurate before changing anything.
  4. src/NT8.Strategies/Examples/SimpleORBStrategy.cs ~926-975 — UpdateConfluenceInputs(), where trend_confirm is computed and written to context.CustomData every 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).
  5. src/NT8.Adapters/Strategies/SimpleORBNT8.cs ~356-370 (post-GAP-061) — GetStateTelemetryContextFields() now surfaces Avwap/AvwapSlope/ TrendConfirm raw values in STATE_CONTEXT. If deployed and observed before this task starts, real AvwapSlope values from live/SIM STATE_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.
  6. tests/NT8.Core.Tests/Intelligence/ — existing tests for TrendAlignmentFactorCalculator (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:

  1. 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.5 must be achievable for both directions when the underlying trend genuinely supports that direction).
  2. No new inputs invented: use avwapSlope (already computed) and whatever direction signal UpdateConfluenceInputs() 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 at UpdateConfluenceInputs() time, explain why in your writeback and propose the minimal way to get it there).
  3. Do not change the additive structure or weights of TrendAlignmentFactorCalculator.Calculate() (+0.4/+0.3/+0.3) — only fix what trend_confirm measures. This task is about correcting the input, not redesigning the scoring formula.
  4. Do not weaken long-side behavior. A long trade's existing trend_confirm value for a positive-slope uptrend must remain 1.0 after 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.3 weights or the additive structure in TrendAlignmentFactorCalculator.Calculate().
  • Do not change how the +0.4 price-vs-AVWAP or +0.3 slopeAligned components are computed — only trend_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 surface TrendConfirm — this task changes what value gets computed, not how it's logged).
  • Do not touch RegimeVeto, the AVWAP hard veto for longs, or EnableShortTrendFilter — separate mechanisms, out of scope.

TESTS (required)

  1. A test proving a short candidate trade in a confirmed downtrend (avwapSlope < 0, direction-consistent) now earns trend_confirm > 0.5 and reaches the same maximum Trend score a symmetric long would reach in a confirmed uptrend.
  2. A test proving a short candidate trade against the trend (avwapSlope > 0, i.e. price trending up while evaluating a short) correctly does NOT earn trend_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).
  3. A test proving long-side behavior is byte-identical to before this change: a long in a confirmed uptrend still scores trend_confirm = 1.0 as it did previously.
  4. Update (do not just add alongside) any existing TrendAlignmentFactorCalculator/UpdateConfluenceInputs test fixtures whose expected values assumed the old direction-blind formula — find them via the existing test files identified in READ-FIRST #6.
  5. 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:

  1. Confirm the build/tests pass per above.
  2. 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?
  3. 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).