Warrior_EA/Expert
Repository files (latest commit first)
Filename Latest commit message Latest commit date
AnimateDread 1a900a0a35 feat(vote): CONSENSUS arithmetic - agreement is now what the threshold dials
Era-680 report, all three observations one equation: "peak 29, no arrows at
threshold 30" / "at 20, arrows on EVERY bar" / "label at 12 while arrows
everywhere". Under the voters-only divisor, any bar with at least one
directional voter read the weighted mean of the firing tiers' weights - and
once the tiers self-ranked to each model's pooled win rate (~28-31), that
mean was NEAR-CONSTANT regardless of headcount. One member alone: ~29. Four
unanimous: ~29. Min_Vote_Open was a step function around that constant -
above it nothing ever fired, below it everything did - and the label's 12
was a 3v1 split netting through the same divisor. Not three display bugs:
one arithmetic that could not express agreement.

The divisor is now the CAPABLE weight - every filter that could vote,
whether it did or not:
 * live (Direction): VoteCapableWeight() - classic pattern ladders always,
   veto filters never, AI members once past the same readiness test
   LongCondition gates on. A model still training must not dilute an
   ensemble it cannot join: four trainees + one deployed model is a solo
   chart wearing an ensemble label, and the solo vote reads full strength.
 * gate (EnsembleEraVerdict): g_ensVoteWeightSum accumulates for every
   member that EVALUATED the bar, Neutral included.
 * overlay sweep + prospective readout: weight counts whenever the member
   has data; a snapshotted Neutral dilutes.
One arithmetic, four sites, same numbers everywhere.

What the numbers become (four members, w~0.29, tiers~29): unanimous ~29 -
the CEILING, which is the pooled win rate and is what the peak displays;
3-of-4 ~22; 2-of-4 ~14.5; 3v1 ~14.5. Min_Vote_Open 20 now means "roughly
three-quarters of the ensemble's trust agrees, net". It MUST sit below the
ceiling to ever fire - the census/peak states the ceiling.

This is the ensemble the user specified in the original design discussion
("if the perceptron also votes, both together reach the threshold; if
another NN votes the other side, the threshold is not reached") - union
semantics was the pre-ensemble behaviour, kept until measurement showed its
vote magnitude was a constant.

Plus overlay DECLUSTERING, the other half of "arrows on every bar": the
same three NMS rules as the per-member arrows (same-direction runs collapse
to their first bar, cross-direction flicker keeps the stronger side), online
over the sweep's strictly oldest->newest walk. Suppression is a verdict and
deletes a standing arrow; the den==0 no-data skip still never does.

NOT COMPILED - user compiles in MetaEditor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 06:58:03 -04:00
..
AIBase feat(vote): CONSENSUS arithmetic - agreement is now what the threshold dials 2026-08-19 06:58:03 -04:00
ADIndicatorTuner.mqh feat(inputs): unify ALL indicator periods under the tuner; EnableAltData input; AI-first defaults 2026-08-16 15:12:54 -04:00
ExpertCustom.mqh fix(chart): the vote readout was repainted once per bar, not once per timer tick 2026-08-18 19:56:06 -04:00
ExpertMoneyCustom.mqh feat(trade): implement trade safety checks per Article 2555 and resource limits 2026-07-26 23:08:32 -04:00
ExpertSignalAIBase.mqh feat(vote): CONSENSUS arithmetic - agreement is now what the threshold dials 2026-08-19 06:58:03 -04:00
ExpertSignalCustom.mqh feat(vote): CONSENSUS arithmetic - agreement is now what the threshold dials 2026-08-19 06:58:03 -04:00
README.md refactor(ai): extract Layer.mqh and deduplicate AI config 2026-08-01 11:27:28 -04:00

Expert/ Directory Documentation

Market-submission compliance (article 2555)

Every runtime check from The Checks a Trading Robot Must Pass Before Publication in the Market is implemented in System/TradeChecks.mqh (free functions, TC* prefix) and applied by the classes in this folder. Where each rule lives:

# Rule Implemented in
1 Catch/fix errors via the tester Development practice; every rejection below logs a throttled reason
2 Insufficient funds TCCheckMoneyForTrade / TCFitVolumeToFreeMargin, applied by CExpertMoneyCustom::ValidateLotForTrade
3 Invalid volumes TCCheckVolumeValue / TCNormalizeVolume, same call site
4 Pending-order count limit TCIsNewOrderAllowed, checked in CExpertSignalCustom::OpenParams and again in CExpertCustom::OpenLong/OpenShort
5 Per-symbol lot limit TCSymbolVolumeAllowed / TCApplySymbolVolumeLimit
6 SYMBOL_TRADE_STOPS_LEVEL TCCheckStops / TCAdjustStops / TCCheckPendingPrice, applied when the setup is shaped and again immediately before the order is sent
7 SYMBOL_TRADE_FREEZE_LEVEL TCFreezeOkForPosition / TCFreezeOkForOrder, gating close, reverse, trailing, order modify and order delete in CExpertCustom
8 Insufficient quote history TCHasEnoughHistory, in CExpertCustom::Refresh and CExpertSignalCustom::OpenParams
9 Array out of range TCIndexOk, plus the existing index guards (iLowest/iHighest return values, Direction()'s bounded loops)
10 Zero divide TCSafeDivide, plus explicit zero-denominator guards on every volume-step / loss division
11 Modification with no changes TCPositionModifyIsMeaningful / TCOrderModifyIsMeaningful, in the TrailingStop* / TrailingOrder* overrides
12 No DLL imports Build-time: WARRIOR_MARKET_BUILD compiles out the #import blocks in AI/NeuronDirectML.mqh
13 No external iCustom Build-time: #resource block in Warrior_EA.mq5 + WARRIOR_CI() in Variables/IndicatorResources.mqh
14 Invalid function parameters TCSymbolIsTradeable, plus the existing ValidationSettings() range checks
15 Access violation No runtime check exists by definition; the NULL-pointer and index guards above are what prevent it
16 CPU / memory consumption TCWarnIfSlow on each OnTick pass (EXPERT_TICK_BUDGET_US) and TCWarnIfMemoryAbove on each timer pass (EXPERT_MEMORY_SOFT_LIMIT_MB)

All rejections report through TCLog(), which throttles per condition so a state that persists for many ticks writes one journal line per minute instead of thousands.

Class hierarchy

CExpert          -> CExpertCustom          (event dispatch, order lifecycle, article-2555 gates)
CExpertMoney     -> CExpertMoneyCustom     (volume correction, margin fitting)
CExpertSignal    -> CExpertSignalCustom    -> CExpertSignalAIBase -> CSignalPAI/CONV/LSTM/HYBRID

ExpertCustom.mqh

Base expert. Virtual handlers for OnTick / OnTimer / OnChartEvent, trading-object setup, series refresh, and the freeze/stops-level gates applied immediately before every send, modify and delete.

ExpertMoneyCustom.mqh

  • CheckAndCorrectVolumeValue — clamps volume to the broker's min/max/step and describes each correction.
  • CheckAndAdjustMoneyForTrade — reduces lots to fit free margin rather than failing the order outright.
  • ValidateLotForTrade — the single gate for rules 2/3/5/14, with throttled logging.

ExpertSignalCustom.mqh

Shared non-AI signal machinery: database-backed signal tracking, pattern weighting, OpenParams() (which shapes SL/TP and applies the min-R:R rejection), and the filter collection. SL_Mode/TP_Mode live here — note they define the AI training target as well as the order, since the triple-barrier label is built from them.

There is no duplicate-trade detection. Three methods that implied otherwise were declared but never defined or called, and were removed in 2026-07. Do not assume the guard exists.

ExpertSignalAIBase.mqh

The AI signal base class. The declaration lives here; the method bodies are split by responsibility into Expert/AIBase/ and included at the bottom of the file, after the declaration. Include them nowhere else.

Expert/AIBase/ holds
Training.mqh era loop, plateau ladder, checkpoint selection, auto-deploy
Topology.mqh network bootstrap, derived shape, conv/LSTM/batch-norm stages
Features.mqh indicator creation, per-bar input feature vector
ChartUI.mqh arrows, arrow persistence, status panel, cleanup
Lifecycle.mqh ctor/dtor, the vote API, tick + chart-event dispatch, config lock
Persistence.mqh .stats / .cfg sidecars, CPU-inference validation
OnlineLearning.mqh live continual learning, EMA shadow, OOS simulator
Labels.mqh triple-barrier labels, async label-cache prebuild
AutoTune.mqh indicator auto-tuner
Inference.mqh softmax, prior calibration, class priors

The topology is derived, not configured — width, taper, depth, conv filters and LSTM hidden size all come from the data shape. See Topology.mqh and Variables/Inputs.mqh for which inputs were removed and why.