Commit graph

8 commits

Author SHA1 Message Date
darashikoh
443ce2d4f2 ERMT_6.9 Compilaton Errors part 1 - complete 2025-09-01 16:55:52 +01:00
63fab7676b The complete Utilities.mqh now includes all the missing implementations:
GetMA() - Moving average calculation
GetBollingerBand() - Bollinger band values
CalculateRiskAmount() - Risk amount from balance and percent
CalculatePipValue() - Pip value calculation
IsSessionActive() - Trading session checking
GetBarTime() - Bar time retrieval
TimeframeToString() - Timeframe conversion
SaveToFile() and LoadFromFile() - File I/O operations
All other utility functions
2025-08-27 16:22:33 +01:00
darashikoh
0404c71a35 3. Utilities.mqh - Remove Duplicates & Add Missing Members
Removed duplicate function definitions
Added missing m_save_log member variable
Added CloseExternalLog() method implementation
Ensured single definition for each logging and report function
2025-08-27 15:53:29 +01:00
0fb1bd1b0a Module Integration Summary for External Trade Management
Overview
To fully integrate the enhanced external trade management system, updates are required to 5 out of 7 existing modules. The updates maintain backward compatibility while adding new functionality for external trade handling.
Module Update Requirements
🟢 No Updates Required (2 modules)

TechnicalAnalysis.mqh - Already provides necessary calculations
EntrySystem.mqh - Only handles EA's own entry signals

🟡 Minor Updates (2 modules)

DataTypes.mqh - Add external trade structures and fields
Utilities.mqh - Enhanced logging for external trades

🟠 Moderate Updates (3 modules)

RiskManager.mqh - Enhanced risk enforcement methods
TradeManager.mqh - Improved stop management for externals
Dashboard.mqh - Display external trade information

Integration Steps
Phase 1: Data Structures (DataTypes.mqh)

Add ENUM_EXTERNAL_STATUS enumeration
Extend ManagedTrade structure with external-specific fields
Add ExternalTradeStats structure for metrics
Update DashboardConfig with show_external flag

Key additions:

external_status - Track state of external trade
source_name - Identify where trade came from
stops_modified - Track if we modified the trade
original_sl/tp - Store original values for comparison

Phase 2: Risk Management (RiskManager.mqh)

Add EnforceRiskRulesEnhanced() method
Implement GetExternalExposure() for risk aggregation
Add UpdateExternalStats() for tracking
Enhance ValidateAndAdjustRiskExternal() method

Key features:

Separate risk calculation for external trades
Cache mechanism for performance
Statistical tracking of external positions
Smart risk adjustment without closing trades

Phase 3: Trade Management (TradeManager.mqh)

Add ApplyDefaultStopsEnhanced() with better logic
Implement OverrideExternalStops() with smart override
Create ManageExternalTrade() with different rules
Add ApplyBreakevenExternal() with wider triggers

Key features:

Smart stop override (only improve, never worsen)
Different management rules for external trades
Respect minimum broker distances
Track modification success/failure rates

Phase 4: User Interface (Dashboard.mqh)

Add CreateExternalSection() for display area
Implement UpdateExternalSection() for real-time updates
Add SetCustomText() for flexible display
Create ShowExternalTrades() toggle method

Key features:

Real-time external trade count and risk
Color-coded risk warnings
List of active external positions
Modification statistics display

Phase 5: Logging (Utilities.mqh)

Add LogExternalTrade() for detailed event logging
Create separate CSV log for external trades
Enhance GenerateReportEnhanced() with external section
Add IdentifyTradeSource() for magic number interpretation

Key features:

Separate CSV log for external trade events
Detailed tracking of all modifications
Source identification from magic numbers
Enhanced reporting with external statistics
2025-08-27 14:21:02 +01:00
darashikoh
bd30cf417a The Problem: In MT5's Strategy Tester environment, file operations are restricted for security reasons. The backtest runs in a sandboxed environment where file creation/writing may be blocked or redirected to a different location.
Key Changes in the Fixed Version:

Testing Mode Detection: Added m_is_testing flag that checks MQLInfoInteger(MQL_TESTER) to detect backtest mode
Conditional File Operations: All file operations are now skipped when in testing mode
Graceful Degradation: The module continues to function without file logging in test mode
Terminal Output: Important messages still print to the terminal during backtesting

Additional Recommendations:
1. Quick Fix Alternative
If you want to test immediately without replacing the file, you can disable logging:
cppinput ENUM_LOG_LEVEL LogLevel = LOG_NONE;  // Set to LOG_NONE in inputs
2025-07-30 14:26:35 +01:00
darashikoh
3295dab1db Summary of Changes to Fix Zero Stop Distance Error
The error "Invalid stop distance: 0.0" was occurring because the entry signals were being generated with invalid (zero) stop distances. This happened when the market volatility (ATR) value was 0 or not properly calculated.
Key Changes Made (Version 6.5.1):

Added GetValidATR() Helper Method in EntrySystem.mqh:

This method ensures we always have a valid ATR value
Includes multiple fallback mechanisms:

Direct ATR calculation if market data is invalid
0.1% of current price as a fallback
Minimum 20 pips for forex pairs




Updated All Entry Strategy Methods to use GetValidATR():

CheckMACrossover()
CheckMAPullback()
CheckMomentum()
CheckContrarian()
CheckBreakout()
CheckMeanReversion()
CheckMultiStrategy()


Enhanced Signal Validation in CheckSignal():

Added explicit check for stop_loss_distance > 0
Signal is rejected if stop distance is invalid
Better error logging to identify which strategy produced invalid signals


Improv
2025-07-30 13:32:29 +01:00
darashikoh
b801040daf Risk Management Overlay EA v6.0 - Code Review and Fix Guide
Critical Issues Found
1. Main EA File (ERMT_6.0.mq5)
Missing Definitions:

EnableLogging variable is used but never defined
Timer initialization missing in OnInit()
Timer cleanup missing in OnDeinit()
Performance metrics initialization not called

Duplicate Code:

CheckEntrySignals() function is defined twice (lines 486 and 577)
HelloWorld example code accidentally included (lines 628-685)

Missing Error Handling:

No connection checks in OnTick()
No auto-trading verification

2. DataTypes.mqh Issues
Duplicate Enumerations:

ENUM_TP_STRATEGY and ENUM_TP_MODE serve the same purpose
Should keep only ENUM_TP_MODE

Inconsistent Structure Fields:

TechnicalLevel has both 'score' and 'strength' fields
ManagedTrade references non-existent ENUM_TP_STRATEGY

Missing Initialization Functions:

No init function for PerformanceMetrics
No init function for EntrySignal

3. Module Inconsistencies
Utilities.mqh:

Two commissio
2025-07-22 16:37:29 +01:00
darashikoh
32705c5d61 1 - Backtest for 1.5 years EURUSD M5 - no trades initia; Critical error on exitlised
2- Compile and debug - Critical error on exit - OnDeinit
3- Fix for Entry System - Add to OnTick():
4 - ENUM_TECHNICAL_LEVEL enum in DataTypes.mqh -> other Enums and structures DataTypes.mqh v3
The Complete DataTypes Module provides the robust foundation needed for your institutional-grade risk management system, offering better trade tracking, risk analysis, and technical integration capabilities essential for professional algorithmic trading.

Moved modules to inside Advisors post-compile 1 debug; became unversioned
2 -
2025-07-20 22:38:24 +01:00