//+------------------------------------------------------------------+ //| Warrior_EA | //| AnimateDread | //| | //| CAIBaseTrainingData bodies - needs the full signal declaration. | //+------------------------------------------------------------------+ #ifndef WARRIOR_TRAINING_AIBASETRAININGDATAIMPL_MQH #define WARRIOR_TRAINING_AIBASETRAININGDATAIMPL_MQH //+------------------------------------------------------------------+ //| EVERY METHOD HERE IS A FORWARD, and that is the whole point. | //| | //| The bounds tests, the sentinels and the "has the gate scored yet" | //| rule all live once, next to the data, in the signal's published | //| read API. This file only maps that API onto CTrainingDataView, so | //| a collaborator can be written, read and replaced without ever | //| naming CExpertSignalAIBase. | //| | //| It holds a BORROWED pointer. The signal owns the adapter, so the | //| owner outlives it by construction - but every call still checks, | //| because a NULL here would be a silent wrong answer rather than a | //| crash, and a diagnostic that quietly reports nothing is worse | //| than one that fails loudly. | //+------------------------------------------------------------------+ int CAIBaseTrainingData::HistoryBars(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataHistoryBars() : 0; } int CAIBaseTrainingData::FeaturesPerBar(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataFeaturesPerBar() : 0; } int CAIBaseTrainingData::LabelResolutionBars(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataLabelResolutionBars() : 1; } int CAIBaseTrainingData::PurgeBars(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataPurgeBars() : 0; } int CAIBaseTrainingData::CalibrationHiIndex(const int totalIter, const int oosCutoff) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataCalibrationHiIndex(totalIter, oosCutoff) : 0; } bool CAIBaseTrainingData::HasLabel(const int bar) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataHasLabel(bar) : false; } bool CAIBaseTrainingData::IsBuyLabel(const int bar) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataIsBuyLabel(bar) : false; } bool CAIBaseTrainingData::IsSellLabel(const int bar) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataIsSellLabel(bar) : false; } bool CAIBaseTrainingData::RowFeatures(const int bar, const int width, double &x[]) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.BaselineRowFeatures(bar, width, x) : false; } bool CAIBaseTrainingData::DirectionalCall(const int bar, bool &isBuy, double &magnitude) { isBuy = false; magnitude = 0.0; return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataDirectionalCall(bar, isBuy, magnitude) : false; } string CAIBaseTrainingData::Id(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataId() : ""; } bool CAIBaseTrainingData::IsEnsembleMember(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataIsEnsembleMember() : false; } int CAIBaseTrainingData::EnsembleIndex(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataEnsembleIndex() : -1; } bool CAIBaseTrainingData::GateReference(double &precPct, int &calls, double &chancePct) { precPct = chancePct = -1.0; calls = 0; return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataGateReference(precPct, calls, chancePct) : false; } double CAIBaseTrainingData::EffectiveSampleSize(const double rawN) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.DataEffectiveSampleSize(rawN) : rawN; } bool CAIBaseTrainingData::Stopping(void) { return (CheckPointer(m_owner) != POINTER_INVALID) ? m_owner.ShutdownRequested() : true; } //+------------------------------------------------------------------+ //| One feature window into a plain double[] - the shape both Alglib | //| predictors take. Fails exactly where the net's own path fails. | //+------------------------------------------------------------------+ bool CExpertSignalAIBase::BaselineRowFeatures(const int bar, const int width, double &x[]) { if(!BuildFeatureWindow(bar) || TempData.Total() < width) return false; for(int f = 0; f < width; f++) { double v = TempData.At(f); if(!MathIsValidNumber(v)) return false; x[f] = v; } return true; } #endif // WARRIOR_TRAINING_AIBASETRAININGDATAIMPL_MQH //+------------------------------------------------------------------+