Warrior_EA/Expert/OnlineLearning/AIBaseOnlineLearningView.mqh

78 lines
4.3 KiB
MQL5
Raw Permalink Normal View History

refactor(online-learning): OnlineLearning is a real collaborator, not a raw-include partial (S5) Expert\AIBase\OnlineLearning.mqh (595 lines) -> Expert\OnlineLearning\: IOnlineLearningView.mqh (abstract, ~50 accessors) + AIBaseOnlineLearningView.mqh/ AIBaseOnlineLearningViewImpl.mqh (the adapter) + OnlineLearning.mqh (COnlineLearning). STATEFUL, unlike CModelPersistence: grep-verified the shadow net, the OOS continual-learning simulation state and the pattern-database backfill state are genuinely exclusive to this file's own methods - Training.mqh/Topology.mqh/ Lifecycle.mqh/the signal's own header only ever CHECKED or RESET this state at era/lifecycle boundaries, never owned it, so it moved onto the collaborator as real members (same doctrine as Excursion). Those external touch points became consolidated view/forward calls instead of raw field pokes - AbortSimIfActive() replaces THREE separate copies of the same delete/null/false triple (Training.mqh's stop path, FlushTrainRun, ResetWeights), matching the geometry-scan duplicate-reset precedent in project memory. ResetForFreshTopology() replaces Topology.mqh's five- field reset block, DeployNet() replaces the shadow-preferred net selection duplicated in Inference.mqh and ChartScoreBarForRescan, and BlendTowardNet() replaces the era-end blend Training.mqh used to poke m_shadowNet for directly. Reused the signal's existing Data*()/Chart*()/Persist*() getters wherever one already answered the question (labels/outcome/history/horizon/priors/servable-bars/etc.); added ~30 new Online*() wrappers only for what nothing else exposed yet. The three PersistOnline*() get/set pairs (WST3 .stats fields) now forward through the owning member instead of touching the field directly - CModelPersistence is unaffected. Every method body is a pure relocation of the original's statements in original order; verified against `git show HEAD~1:Expert/AIBase/Excursion.mqh`-style diff against the pre-extraction file kept in the working tree until this commit. Compiled 0 errors, 0 warnings (stage mirror + MetaEditor64 /compile, ~91s). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 22:59:02 -04:00
//+------------------------------------------------------------------+
//| Warrior_EA |
//| AnimateDread |
//| |
//| CAIBaseOnlineLearningView - declarations only, bodies in |
//| AIBaseOnlineLearningViewImpl.mqh (needs the full signal declared).|
//| Same shape as Persistence\AIBasePersistenceView.mqh. |
//+------------------------------------------------------------------+
#ifndef WARRIOR_ONLINELEARNING_AIBASEONLINELEARNINGVIEW_MQH
#define WARRIOR_ONLINELEARNING_AIBASEONLINELEARNINGVIEW_MQH
#include "IOnlineLearningView.mqh"
class CExpertSignalAIBase;
class CAIBaseOnlineLearningView : public COnlineLearningView
{
private:
CExpertSignalAIBase *m_owner;
public:
CAIBaseOnlineLearningView(void) : m_owner(NULL) { }
void Bind(CExpertSignalAIBase *owner) { m_owner = owner; }
virtual string Id(void) override;
virtual string ActiveFileName(void) override;
virtual bool ActiveFileCommon(void) override;
virtual long EraCount(void) override;
virtual bool TrainingComplete(void) override;
virtual bool IsEnsembleMember(void) override;
virtual double ErrorPct(void) override;
virtual double UndefinePct(void) override;
virtual double Forecast(void) override;
virtual datetime StudiedTime(void) override;
virtual CNet *NetPtr(void) override;
virtual CArrayDouble *TempData(void) override;
virtual int OutputNeurons(void) override;
virtual bool BuildFeatureWindow(const int bar) override;
virtual double ApplyClassificationSoftmax(void) override;
virtual double AdjustedSignalFromSoftmax(void) override;
virtual ENUM_SIGNAL SignalFromValue(const double v) override;
virtual ENUM_SIGNAL BarLabel(const int bar) override;
feat(target): delete the barrier/geometry stack - the label is the verdict Step 3 of the swing-pivot plan, whole-hog. The swing label is now the ONE target and the era verdict is precision + recall per class against the label's own base rate - no win rate, no break-even, no expectancy, no geometry anywhere in training. DELETED - Expert/Excursion/ (4), Expert/BarrierHorizon/ (4), GeometrySweep, FirstPassageLadder, Labeling/TripleBarrier.mqh (CLabelOverlap survives in Labeling/LabelOverlap.mqh), 3 test EAs. - TripleBarrierLabel + walk, fractal label, geometry derivation/scan/ adoption, exit-policy replay, excursion MI targets, the drift verdict (DIRECTION_INTELLIGENT), the recall floor, balanced-accuracy telemetry, the barrier defines, the .cfg geometry adopt (slots kept as zeros for the positional layout), the derived-geometry live-order override. - TRAINING_TARGET input/enum: direction models are always swing; META2 re-keys the meta head onto label agreement (descriptor loses its two geometry slots). REWORKED - Labels.mqh (1795 -> ~370 lines): AdvanceSwingLabelState with FINALITY-GATED CACHING - an unresolved bar (pivot pair uncommitted) is never cached, so it can never freeze as a false Neutral; training, calibration, OOS scoring and online learning all skip unresolved bars. - SDeployVerdict: significance-only; SOosTally chance = larger directional class share; pooled gate poolability = timeframe (record v2). - Purge/embargo/declustering gaps: the measured mean label resolution lag (LabelResolutionBars), not a barrier horizon. - Pool purge key + backfill DB rows: marked at the bar the label resolved on (m_labelResolveAge), not a fabricated barrier touch. - Online learning frontier: finality, not a horizon delay. - m_bestBalancedOos -> m_bestSelectionScore, m_erasSinceBestBalanced -> m_erasSinceBest, ensemble vote outcome arrays -> label arrays. STEP 4 folded in: Entry_Multiplier / SL_Mode / TP_Mode / tradingdirection are inputs again - trade management is the tester GA's search space. Fingerprints: every direction model re-keys (TGT:SWG1 now unconditional, CUT token gone); META1 -> META2. Full retrain, as planned. Compile-verified in _claude_stage: Warrior_EA + both surviving test EAs, 0 errors, 0 warnings each. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 20:42:31 -04:00
virtual int LabelResolveAge(const int bar) override;
refactor(online-learning): OnlineLearning is a real collaborator, not a raw-include partial (S5) Expert\AIBase\OnlineLearning.mqh (595 lines) -> Expert\OnlineLearning\: IOnlineLearningView.mqh (abstract, ~50 accessors) + AIBaseOnlineLearningView.mqh/ AIBaseOnlineLearningViewImpl.mqh (the adapter) + OnlineLearning.mqh (COnlineLearning). STATEFUL, unlike CModelPersistence: grep-verified the shadow net, the OOS continual-learning simulation state and the pattern-database backfill state are genuinely exclusive to this file's own methods - Training.mqh/Topology.mqh/ Lifecycle.mqh/the signal's own header only ever CHECKED or RESET this state at era/lifecycle boundaries, never owned it, so it moved onto the collaborator as real members (same doctrine as Excursion). Those external touch points became consolidated view/forward calls instead of raw field pokes - AbortSimIfActive() replaces THREE separate copies of the same delete/null/false triple (Training.mqh's stop path, FlushTrainRun, ResetWeights), matching the geometry-scan duplicate-reset precedent in project memory. ResetForFreshTopology() replaces Topology.mqh's five- field reset block, DeployNet() replaces the shadow-preferred net selection duplicated in Inference.mqh and ChartScoreBarForRescan, and BlendTowardNet() replaces the era-end blend Training.mqh used to poke m_shadowNet for directly. Reused the signal's existing Data*()/Chart*()/Persist*() getters wherever one already answered the question (labels/outcome/history/horizon/priors/servable-bars/etc.); added ~30 new Online*() wrappers only for what nothing else exposed yet. The three PersistOnline*() get/set pairs (WST3 .stats fields) now forward through the owning member instead of touching the field directly - CModelPersistence is unaffected. Every method body is a pure relocation of the original's statements in original order; verified against `git show HEAD~1:Expert/AIBase/Excursion.mqh`-style diff against the pre-extraction file kept in the working tree until this commit. Compiled 0 errors, 0 warnings (stage mirror + MetaEditor64 /compile, ~91s). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 22:59:02 -04:00
virtual bool HasLabel(const int bar) override;
virtual bool IsBuyLabel(const int bar) override;
virtual bool IsSellLabel(const int bar) override;
virtual int HistoryBars(void) override;
virtual int CalibPurgeBars(void) override;
virtual int CalibLoIndex(const int oosCutoff) override;
virtual int CalibHiIndex(const int totalIter, const int oosCutoff) override;
virtual int CalibBandBars(const int totalIter, const int oosCutoff) override;
virtual double PriorBuy(void) override;
virtual double PriorSell(void) override;
virtual double PriorNeutral(void) override;
virtual bool InferenceOnly(void) override;
virtual bool TrainRunActive(void) override;
virtual bool TrainingStopRequested(void) override;
virtual bool TrainingPaused(void) override;
virtual int AvailableBars(void) override;
virtual int ServableBars(const int want, const string context) override;
virtual bool ResizeBuffers(const int barIndex) override;
virtual bool RefreshData(void) override;
virtual bool EnsureBarCachesCapacity(const int bars) override;
virtual datetime BarTime(const int idx) override;
virtual double CloseAt(const int idx) override;
virtual double AtrAt(const int idx) override;
virtual double SpreadPrice(void) override;
virtual string FilterId(void) override;
virtual int ConfidenceTierNow(void) override;
virtual double PatternWeightForTier(const int tier) override;
virtual string PatternTableName(const string filterId, const string pattern, const string direction) override;
virtual void RegisterSignalRow(int year, int month, int day, int DOW, int hour, int minutes,
string tableName, string pattern, string direction,
double entryPrice, double exitPrice, string result, double netVote) override;
virtual double PrevSignal(void) override;
virtual void SetPrevSignal(const double v) override;
virtual bool SaveModelStatsNow(void) override;
virtual void FlattenIndicatorParams(double &ip[]) override;
virtual double ModelEta(void) override;
};
#endif // WARRIOR_ONLINELEARNING_AIBASEONLINELEARNINGVIEW_MQH
//+------------------------------------------------------------------+