Skip to content

Testing and Validation

node3 edited this page Sep 16, 2026 · 10 revisions

Testing and Validation

The gates CI workflow enforces the analysis gates; the two MetaTrader gates run locally. Record what was actually run, and do not treat static review as a successful compile or runtime test.

The Gates

Gate Command What it proves
Compile ./tools/build-macos.sh Syntax and types; exits non-zero on any error or warning.
Census tools/census.py No uncalled function, unreferenced input / #define / global / enum member, write-only struct field, write-only local, unused parameter, placeholder token or string literal in a StringFormat slot.
Contracts tools/contracts.py The verdict labels, result line, parsed report fields and harness install path still agree across the indicator, the harness and the gate scripts, and the dashboard still refreshes its history cache before branching on display mode. None of this is visible to the compiler.
Self-test ./tools/selftest-macos.sh Every assertion in eight groups passes inside the terminal; the result line prints the total.

All four must pass before a commit; the Release Checklist adds the historical runs and the manual scenarios. selftest-macos.sh runs the contract check itself before compiling, so a broken contract is reported as a contract rather than as a timeout.

What CI Covers, and What It Cannot

The gates workflow runs on every push and every pull request: the census, the contract check, ruff check and format, mypy --strict, bandit, shellcheck, shfmt -d, and a gitleaks scan of the full history rather than just the tip.

It deliberately does not run the compile or the self-test. Those need Wine, Rosetta 2 on Apple Silicon, and a terminal with broker history, which a hosted Linux runner cannot provide. A green workflow therefore means the analysis gates passed, not the release is verified — treat a green badge as necessary and never sufficient, and run the two MetaTrader gates on a Mac before any release. The tool versions are pinned in the workflow and match AUDIT/environment.md, so a local run and a CI run mean the same thing.

Minimum Validation

Change type Required checks
Wiki or README only Check links, spelling, source consistency, input coverage, terminology, and staged files
Any FXNews.mq5 change All four gates
Startup or input handling Attach with valid defaults and verify intended invalid-input rejection
Scoring or state All four gates, a --validation run, then a Live scan in a demo terminal inspecting reasons, caps, state transitions, and cooldowns
Dashboard Verify status, optional diagnostics, active rows, the recent-signal list in the default mode, tooltips, resizing, and cleanup
Alerts Test only the changed opt-in channel; verify correlation-leader dispatch, the per-profile spacing, the global limit and the retry cap
Calendar Test with calendar context disabled and enabled when MT5 data is available
Historical logic --validation and --autotune through the harness, then a run over the intended basket, inspecting the complete Journal report

Self Test

Set OperatingMode = FXNEWS_MODE_SELFTEST and attach the indicator, or run the harness below. It needs no symbols, no buffers and no market data, prints a report to the Journal and shows a pass/fail summary on the chart. The result line prints the assertion total, so this page never has to.

Groups:

  • ramps and clamps: SmoothStep, ScoreFromZ, LinearScore, Clamp;
  • robust statistics: RobustZ (including the sigma floor and the zero-dispersion case), MedianOfArray, MedianAbsDeviation, SafeDiv, median(-x) == -median(x);
  • time and session: NormalizeHour, HourInSession;
  • symbols and timeframes: PipSize, TimeframeMinutes, ParseTimeframeToken, FindBaseQuoteCurrencies, ObjectNamespaceToken (only object-name-safe characters);
  • scoring helpers: ApplyScoreCap, ScoreBucketFloor, BlockStageRank, MeetsThreshold rounding like the displayed percentage;
  • availability and composer: unmeasured execution and regime terms leave the blends, the shared composer caps a basket-less score at 84, excludes an unmeasured engine from the normaliser, expires at the age limit while keeping the age-free score, applies the late-event cap and the raw MTF reject level; ComputeBreakoutStructure on a tiny and a strong candle; PadRight, FormatLocalTimestamp, WrapLabelText;
  • historical engine, on a synthetic minute series with a ten-minute gap: grid boundaries, index search, time-based bar aggregation and coverage rejection, ATR, range box, spread column, tick-volume z, every outcome case (target first paying the spread, stop first, undecided, gapped horizon, target and stop in one minute), bucket routing, profit-factor proxy, score edge, the objective floor;
  • signal history: insert with reason, in-place update, sub-threshold rejection, newest-first order at capacity, both eviction rules, the rounded list threshold.

Stateful behaviour that the self-test does not cover: the live signal lifecycle, correlation grouping, alert dispatch and the dashboard rendering. Those need the manual scenarios below.

Headless runs on macOS

./tools/selftest-macos.sh
./tools/selftest-macos.sh --validation
./tools/selftest-macos.sh --autotune

The script compiles the indicator and the harness script tools/mql5/FXNewsSelfTest.mq5, installs the build under MQL5/Indicators/FXNews-selftest/ (never the live FXNews/ folder), starts the terminal with a one-shot startup configuration that runs the harness on an EURUSD M5 chart, waits for the verdict label, reads the Experts journal and exits 0 only on SELFTEST PASSED with zero failed assertions, or on a complete VALIDATION / AUTOTUNE report over EURUSD and GBPUSD on M5 and H1. The harness files are removed again on exit. The terminal must not be running when it starts; the self-test takes about 20 seconds.

The historical modes need M1 history at run time. --validation and --autotune exit non-zero unless the report shows loaded symbols, loaded M1 bars and evaluated boundaries. A report over no data is not a quiet report, it is an empty one, and it used to pass. The one-shot terminal authorizes and shuts down within a couple of seconds, which is not long enough to trigger an on-demand download of ninety days of M1, so on a machine that has not opened these symbols recently the gate fails with "read no history: 0 symbol(s) loaded, 0 M1 bar(s)" and tells you to open an M1 chart for each symbol first. That failure is truthful, not a flake: it means the historical engine was never exercised. Pre-open the basket's M1 charts and let them download before running the historical modes, and treat a green historical gate that reports zero bars as a defect rather than a pass.

Dead-Code Census

tools/census.py

tools/census.py (Python 3.14) runs the census deterministically and exits non-zero on any open finding. It reports uncalled functions (the event handlers are exempt), unreferenced inputs, #defines, globals and enum members, struct fields written but never read, locals assigned and never read, parameters never used (default values are stripped first), placeholder tokens in string literals, and string literals passed into StringFormat slots. Deliberate exceptions go into tools/census-allow.txt, one identifier per line, and are reported as allowed.

The compiler cannot do this: it warns only about a variable that is never touched at all, so an initialised-but-unread local, a dead struct copy, a struct field written but never read, a tautological comparison and unreachable code all compile silently.

Manual Scenarios

Compile and Startup

Run all four gates. Attach the compiled indicator to a chart in a demo or non-production terminal with default settings. Confirm the status line appears, no trade operation occurs, and no unexpected file is created.

Symbol and Timeframe Parsing

Test comma, semicolon, newline, and tab-separated symbol lists, duplicate entries, a bare name next to its suffixed alias (they must collapse to one set of profiles), an unavailable symbol, and a non-FX symbol (skipped with a status message). Test every supported timeframe token including numeric and PERIOD_ forms, and confirm that an unsupported token rejects initialisation.

Component Availability

Right after attaching, blocked-signal debug rows should read no_movement_data and tooltips should show unmeasured components until the spread ring, the speed baselines and the basket have filled. Run with UseCurrencyStrength=false and confirm rows show FLOW_OFF, never FLOW+, and tooltips read "currency basket not evaluated". With UseEconomicCalendarContext=false, confirm the calendar tag reads NEWS_OFF and no tooltip claims "no high-impact news nearby". Then enable each and confirm the affirmative wording returns only when a reading actually exists.

Alert Delivery

With one channel enabled, force a burst that exceeds the per-profile spacing and the global limit, and confirm that a held alert is sent on a later scan rather than lost, that no more than two go out per scan, and that a failed delivery is retried three times and then dropped with a Journal line. Read one push notification end to end and confirm every token in it means something.

Scoring and State

In a safe terminal, enable DebugScoreBreakdown and DebugPrintToJournal when detailed inspection is needed. Confirm block and cap reasons match the observed data, active signals expire at SignalTTLSeconds, a candidate in CONFIRM_BAR_CLOSE survives until the next bar opens on every scan timeframe, failed and valid cooldowns are respected, a reversal enters through the candidate path, and the score is never presented as a guaranteed probability.

Dashboard

In the default mode confirm the recent-signal list renders a new entry on the scan it appears, keeps faded entries until eviction, and that its tooltips carry the reason. With ShowActiveSignalRows=true confirm row 1 shows activity status, rows 2 and 3 follow ShowDiagnosticsPanel, signal rows start below them, every row fits the 63-character label budget, and the tooltip carries cost, calendar, session, group and tags. Verify MaxDashboardRows, ShowSessionOnDashboard, ShowOnlyGroupLeaders, and ShowBlockedSignalsDebug. Resize the chart and confirm rows re-fit on the next scan, then remove the indicator and confirm its chart objects are deleted.

Confirmation, Alerts, and Historical Modes

Exercise all three confirmation modes. Test alert grouping with ShowOnlyGroupLeaders both enabled and disabled: it must only affect dashboard rows, while alert dispatch remains limited to the group leader. Then deliberately create a burst to verify the global alert limit.

With sufficient broker M1 history, run FXNEWS_MODE_VALIDATION and inspect the coverage lines, the spread source mix, signal count, bucket quality, average R, target-first and stop-first rates, profit-factor proxy and score edge. Run FXNEWS_MODE_AUTOTUNE when candidate-selection logic changes; verify that it leaves runtime settings unchanged, reports its recommendation with the proxy parameter marked as such, and stays parked with the report on the chart.

Documentation Validation

For README or wiki changes:

  1. Compare every behavior claim and input default with current FXNews.mq5.
  2. Verify that every source input appears in the Configuration reference.
  3. Check internal wiki links and public README links.
  4. Scan for obsolete page names and unsupported claims.
  5. Confirm that FXNews.mq5 is unchanged for a documentation-only task.

Environment-Sensitive Areas

  • Broker symbol naming and Market Watch availability.
  • Gaps or limited depth in M1 and tick history, and brokers whose M1 bars carry no spread column.
  • CopyRates and CopyTicks performance.
  • MT5 economic-calendar availability.
  • Chart font and object rendering across terminal builds and display settings; the 63-character label limit was verified on build 6198.

Use the Release Checklist for the final production gate.

Clone this wiki locally