# Expert/ Directory Documentation ## ExpertCustom.mqh - **Purpose:** Defines the `CExpertCustom` class, a base class for custom expert advisors in the EA framework. - **Inheritance:** Inherits from `CExpert` (not shown here, likely a core MQL5/MetaQuotes class or defined elsewhere in the project). - **Key Features:** - Provides virtual event handlers for MQL5 events: `OnTick`, `OnTimer`, `OnChartEvent`, etc., allowing derived classes to implement custom trading logic. - Contains methods for initializing trading objects, handling series data, and managing trading events. - Designed for extensibility: users can derive their own expert logic by subclassing and overriding the provided virtual methods. - **Modernization Note:** - This class is a good candidate for further abstraction to support AI/ML-driven strategies. Consider introducing interfaces or abstract base classes for signal generation, money management, and risk control, allowing plug-and-play of traditional and AI/ML modules. - Ensure all event handlers are unit-testable and decoupled from hard-coded logic. ## ExpertMoneyCustom.mqh - **Purpose:** Implements a custom money management class (`CExpertMoneyCustom`) for the EA, extending `CExpertMoney`. - **Key Features:** - `CheckAndCorrectVolumeValue`: Ensures trade volume is within broker constraints (min/max/step), adjusting and describing corrections. - `CheckAndAdjustMoneyForTrade`: Dynamically adjusts lot size to fit available margin, reducing lots if margin is insufficient, and handles errors gracefully. - **Modernization Note:** - This class is a good candidate for AI/ML-driven position sizing. Consider abstracting the logic to allow for ML-based risk and lot size optimization. - Ensure all adjustments are logged for transparency and auditability. ## ExpertSignalAIBase.mqh - **Purpose:** Provides a base class (`CExpertSignalAIBase`) for AI/ML-driven signal generation, extending `CExpertSignalCustom`. - **Key Features:** - Integrates with the neural network/AI subsystem (`Network.mqh`). - Manages a wide range of indicator objects (Open, Close, High, Low, Volumes, AD, ADX, MACD, etc.) for feature extraction. - Supports dynamic configuration of neural network topology, training, and feature selection. - Implements methods for indicator initialization, data buffering, training, and topology persistence. - **Modernization Note:** - This is the main integration point for advanced ML/AI logic. Ensure all feature selection and training parameters are externally configurable. - Refactor to support plug-and-play feature pipelines and automated hyperparameter optimization. ## ExpertSignalCustom.mqh - **Purpose:** Implements a custom signal logic class (`CExpertSignalCustom`) for the EA, extending `CExpertSignal`. - **Key Features:** - Adds database-driven signal tracking, pattern recognition, and trade record management. - Supports dynamic filter addition, ATR-based entry/exit logic, and advanced signal buffering. - Implements robust duplicate detection, trade status management, and event-driven signal processing. - **Modernization Note:** - This class is central to integrating traditional and AI/ML signals. Refactor to decouple hard-coded logic and support dynamic, testable signal pipelines. - Ensure all database operations are abstracted for testability and future migration to more advanced data stores. --- (Other files in Expert/ will be documented as they are processed.)