Warrior_EA/Expert/Features/IFeaturesView.mqh
AnimateDread b2784b5a4d Enhance Feature and Topology Interfaces with Bulk Operations and Cache Management
- Added bulk read/write methods for feature caches in IFeaturesView and its implementations to optimize performance.
- Introduced LabelCacheInvalidateAll method to manage label cache invalidation alongside feature cache.
- Implemented PooledIndependentBars method in topology interfaces to account for additional independent observations.
- Enhanced risk budget management with throttling for peak-equity updates to reduce unnecessary file operations.
- Improved error handling and logging for ATR trailing stops to ensure better visibility of issues.
- Updated alt-data handling to prevent unnecessary operations during testing and optimization phases.
2026-08-25 22:51:50 -04:00

101 lines
6 KiB
MQL5

//+------------------------------------------------------------------+
//| Warrior_EA |
//| AnimateDread |
//| |
//| The read/write surface CFeatureBuilder needs from the signal. |
//| Same shape as Topology\ITopologyView.mqh - abstract, pure `= 0`, |
//| no signal include. m_Open/m_Close/m_High/m_Low/m_Time/m_ATR/ |
//| m_zigZag stay signal-owned (real .GetData()/.Main() reads in |
//| Labels.mqh/AutoTune.mqh/Training.mqh too) and are reached here |
//| read-only; m_indicatorTuner/m_crossAsset/m_altData are handed |
//| over as whole-object pointers (their own classes already declare |
//| the needed methods/fields public) rather than one accessor per |
//| field/call - same doctrine as TempData(). |
//+------------------------------------------------------------------+
class CFeaturesView
{
public:
virtual ~CFeaturesView(void) { }
//--- IDENTITY + SIZE (reused via the signal's existing Data*()/Chart*() getters)
virtual string Id(void) = 0;
virtual string SymbolName(void) = 0;
virtual ENUM_TIMEFRAMES Timeframe(void) = 0;
virtual int HistoryBars(void) = 0;
virtual int NeuronsCount(void) = 0;
virtual int LabelResolutionBars(void) = 0;
virtual double EffectiveSampleSize(const double rawN) = 0;
virtual double MeanLabelLifespan(void) = 0;
virtual int FirstLayerFanIn(void) = 0;
virtual double SwingLifespanEstimate(void) = 0;
virtual double EstimatedInSampleBarsRaw(void) = 0;
virtual double ChanceRatePct(void) = 0;
virtual bool UseAltData(void) = 0;
virtual int SwingConfirmationBars(void) = 0;
virtual int NewsFeatureWindowMinutes(void) = 0;
virtual int InitialNeuronsCount(void) = 0;
virtual string ActiveFileName(void) = 0;
//--- FEATURE-FLAG SWITCHES - every one already has a signal-side getter, reused directly.
virtual bool UseVolumes(void) = 0;
virtual bool UseMA(void) = 0;
virtual bool UseATR(void) = 0;
virtual bool UseTime(void) = 0;
virtual bool UseSwingContext(void) = 0;
virtual bool UseNews(void) = 0;
virtual bool UseSpreadFeature(void) = 0;
virtual bool UseCrossAsset(void) = 0;
//--- SHARED PRICE/INDICATOR SERIES - read-only windows, never the Init/Resize/Refresh lifecycle
//--- (that stays in Expert\AIBase\Features.mqh - see InitOpen's declaration comment).
virtual double OpenAt(const int idx) = 0;
virtual double HighAt(const int idx) = 0;
virtual double LowAt(const int idx) = 0;
virtual double CloseAt(const int idx) = 0;
virtual datetime TimeAt(const int idx) = 0;
virtual double AtrMain(const int idx) = 0;
virtual int AtrBarsCalculated(void) = 0;
virtual int AtrHandle(void) = 0;
virtual int ZigZagBarsCalculated(void) = 0;
virtual int ZigZagHandle(void) = 0;
virtual bool FindConfirmedZigZagPivot(const int fromIdx, int &pivotIdx, double &pivotPrice, bool &pivotIsLow) = 0;
virtual double SymbolPoint(void) = 0;
//--- INDICATOR PLUMBING
virtual CIndicators *IndicatorsPtr(void) = 0;
virtual CADIndicatorTuner *IndicatorTuner(void) = 0;
virtual CCrossAssetPanel *CrossAsset(void) = 0;
//--- ALT-DATA PANEL
virtual int AltDataFeatureCount(void) = 0;
virtual void AltDataEnsureFresh(const datetime asOf) = 0;
virtual void AltDataFeatures(const datetime t, double &out[]) = 0;
//--- CROSS-ASSET PIN PERSISTENCE (the .cfg pin, reused Persist* getters/setters)
virtual string CrossAssetPairsPinned(void) = 0;
virtual void SetCrossAssetPairsPinned(const string v) = 0;
virtual bool CrossAssetCfgSaved(void) = 0;
virtual void SetCrossAssetCfgSaved(const bool v) = 0;
virtual bool CommitCrossAssetPin(void) = 0;
//--- FEATURE-ROW CACHE (m_featureCache/m_featureCacheHasValue/m_featureCacheValid) - stays
//--- signal-owned (Labels.mqh ArrayResize()s it, Training.mqh ArrayInitialize()s it).
virtual int FeatureCacheSize(void) = 0;
virtual bool FeatureCacheHasValue(const int idx) = 0;
virtual bool FeatureCacheIsValid(const int idx) = 0;
virtual double FeatureCacheAt(const int flatIdx) = 0;
//--- Bulk cache-hit read: one ArrayCopy instead of `count` individual FeatureCacheAt() calls, each
//--- of which was a CheckPointer + two virtual dispatches for a single double. Same values, same
//--- order - see CFeatureBuilder::BufferTempData()'s cache-hit branch, the only caller.
virtual void FeatureCacheBlock(const int base, const int count, double &out[]) = 0;
virtual void FeatureCacheSetAt(const int flatIdx, const double v) = 0;
//--- Bulk counterpart to FeatureCacheBlock() above, for the cache-MISS/fresh-compute write side -
//--- see CFeatureBuilder::BufferTempDataCompute()'s cache-store block, the only caller.
virtual void FeatureCacheSetBlock(const int base, const int count, const double &values[]) = 0;
virtual void FeatureCacheMarkStored(const int idx) = 0;
virtual void FeatureCacheInvalidateAll(void) = 0;
//--- Labels read m_ATR/m_zigZag (Labels.mqh), not just the feature indicators, so a repair that
//--- invalidates the feature cache must invalidate this one too - see the call sites in
//--- FeatureBuilder.mqh's ReInitTunableIndicators()/RepairDeadIndicatorHandles().
virtual void LabelCacheInvalidateAll(void) = 0;
//--- FAIL-DIAGNOSTIC MIRRORS - Training.mqh reads these directly for the pass-1 stall report.
virtual void SetFailBlock(const string block) = 0;
virtual void SetFailIdx(const int idx) = 0;
virtual void SetWindowFail(const int slot, const int total) = 0;
//--- SHARED SCRATCH BUFFER
virtual CArrayDouble *TempData(void) = 0;
};
//+------------------------------------------------------------------+