Commit graph

92 commits

Author SHA1 Message Date
darashikoh
4951f74957 Recompile and re-debug of ERMT_6.6; the last functional EA for external management 2025-08-20 12:53:47 +01:00
darashikoh
5dce04606c new files added 2025-08-20 10:52:10 +01:00
darashikoh
050880d47e Merge commit from 'origin' 2025-08-19 18:36:58 +01:00
darashikoh
8b1ff58567 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ad5ddad485 Merge pull request 'WIP-ERMT-Recovery of lost files - 18082025' (#1) from ERMT-ML into main
Reviewed-on: #1
2025-08-19 17:28:48 +00:00
a559f7ae04 Update Experts/Advisors/ERMT_7.1_ERMT-ML.mq5 2025-08-19 17:16:43 +00:00
7caa89db31 Update Experts/Advisors/ERMT_7.1_main.mq5 2025-08-19 17:16:02 +00:00
darashikoh
ff69c0f3ad 2025-08-15 23:05:57 +01:00
darashikoh
19493874a2 2025-08-15 14:56:24 +01:00
darashikoh
9c05f130ea new files added 2025-08-15 14:53:55 +01:00
darashikoh
4e7d1b3bb6 2025-08-15 13:14:24 +01:00
darashikoh
c7a617709f Resolution of git index lock due to VS Code repo editing 2025-08-13 01:34:23 +01:00
darashikoh
d6eccab613 Resolution of git index lock from VS Code 2025-08-13 01:33:37 +01:00
darashikoh
d346ae6a94 2025-08-08 20:32:34 +01:00
39c0d6785c 1. Ultra-Low Latency Processing
Tick Caching System: Circular buffer for batch processing ticks
Millisecond Timer: Configurable tick processing interval (default 1ms)
Pre-calculated Symbol Data: All symbol specifications cached for instant access
Lock-free Data Structures: Atomic operations for concurrent access

2. Machine Learning Integration

ML Prediction Engine: Adaptive entry signal enhancement
Deep Neural Network Support: Optional deep learning for complex patterns
Real-time Model Updates: Continuous learning from trade outcomes
Confidence-based Position Sizing: ML confidence affects position size

3. Advanced Risk Analytics

Value at Risk (VaR): Real-time portfolio VaR calculation
Conditional VaR (CVaR): Tail risk measurement
Correlation Matrix: Dynamic correlation tracking across all positions
Portfolio Beta: Market exposure measurement
Stress Testing: Automated portfolio stress scenarios

4. Smart Order Execution

Adaptive Execution Algorithms: TWAP, VWAP, and custom algos
Iceberg Orders: Hide large order size from market
Smart Order Routing: Optimize execution across liquidity pools
Slippage Reduction: Predictive models to minimize slippage
Execution Quality Tracking: Real-time metrics on fill quality

5. Order Flow Analysis

Volume Profile Analysis: Identify key liquidity levels
Institutional Flow Detection: Spot large block trades
Flow Imbalance Signals: Order flow momentum indicators
Liquidity Scoring: Real-time liquidity assessment per symbol

6. Portfolio Optimization

Markowitz Optimization: Efficient frontier calculations
Dynamic Rebalancing: Automatic weight adjustments
Correlation-based Risk Limits: Prevent over-correlation
Multi-Asset Support: Handle 50+ symbols simultaneously

7. Institutional Reporting

FIX Protocol Ready: Gateway ID support for institutional connectivity
Performance Attribution: Detailed P&L breakdown
Regulatory Compliance: Audit trail and reporting
Real-time Analytics: Sub-second performance updates

8. Performance Optimizations

Memory Pool Allocation: Pre-allocated memory for speed
Batch Position Updates: Process all positions in one pass
Optimized Data Structures: Cache-friendly memory layout
Minimal Logging: Reduced I/O in production mode
2025-08-08 11:05:06 +01:00
darashikoh
926b6c195a 2025-08-05 13:20:50 +01:00
darashikoh
9f3303dbc2 Major Fixes Implemented:
1. Multi-Symbol Detection Fixed

Replaced the broken CheckForNewExternalTradesMultiSymbol() with CheckForNewExternalTradesEnhanced()
Added dynamic symbol detection that automatically finds all traded symbols
Fixed position selection logic that was preventing multi-symbol detection

2. Enhanced Trade Management

Created CreateManagedTradeEnhanced() that properly handles multi-symbol trades
Added symbol-specific ATR calculation for each symbol
Fixed the AddManagedTrade() function to return boolean and validate trades

3. Comprehensive Diagnostics

Added RunExternalTradeDiagnostics() for detailed troubleshooting
Added MonitorPositions() for real-time position monitoring
Added debug mode with visual feedback on chart

4. New Features Added

Keyboard Shortcuts:

Press 'D' for diagnostics
Press 'R' to refresh external trades
Press 'T' to generate report


Auto-detect symbols option for dynamic monitoring
Debug mode for troubleshooting
Better logging throughout
2025-08-04 22:50:57 +01:00
darashikoh
2a617b1dab 2025-08-01 11:25:48 +01:00
darashikoh
f14cb7649f Rename to v7.0 2025-08-01 11:25:16 +01:00
darashikoh
9b1c52209b BRANCH ERMT v7 Enhanced Dashboard, MultiTrade Reporter, External Trade management M1-4 compile and debug 2025-08-01 11:13:35 +01:00
darashikoh
9afaf5efaf Summary
I've provided you with a comprehensive solution for managing your commercial EA trades using the Risk Management Overlay EA, despite MT5's one-EA-per-chart limitation:
1. Complete Management Guide

4 different methods to run both EAs
Detailed setup instructions for each method
Configuration examples for different scenarios

2. Quick Setup Card

5-minute setup for the most common scenario
Essential configuration templates
Visual dashboard examples

3. EA Detection Utility

Automatically detects all running EAs
Shows magic numbers and trade counts
Provides configuration suggestions

4. Method Selection Flowchart

Simple decision tree to choose the best method
Comparison of difficulty and resources
Specific recommendations based on your needs

Recommended Approach
For your commercial EA on forex pairs, I recommend:

Start with Method 1 (Different Timeframes):

Put your commercial EA on H1 chart
Put Risk Manager on M15 chart of same pair
This is the simplest and most reli
2025-08-01 10:56:06 +01:00
darashikoh
56a1014695 Established enhanced dashboard and advanced reporting for external trades 2025-07-31 19:52:26 +01:00
darashikoh
82c958b8a4 2025-07-30 20:50:27 +01:00
darashikoh
56209c4d63 Summary of Fixes
The "Stop distance must be greater than 0" error is caused by a chain of issues in the ATR calculation. Here's what you need to do:
1. Replace the GetValidATR function in EntrySystem.mqh
The original code had a recursive call bug. Replace the entire EntrySystem.mqh file with the fixed version I provided above.
2. Update the GetATR method in TechnicalAnalysis.mqh
Replace the GetATR method with the fixed version that includes fallback calculations.
3. Update the AnalyzeMarket method in TechnicalAnalysis.mqh
Replace the AnalyzeMarket method with the enhanced version that ensures volatility is always valid.
4. Update the main EA file (ERMT_6.0.mq5)
Replace the CheckEntrySignals() and UpdateMarketConditions() functions with the enhanced versions that include debugging and validation.
Key Changes Made:

Fixed Recursive Bug: The GetValidATR function was calling itself instead of using market.volatility
Added Multiple Fallbacks:

Primary: Use market.volatility from TechnicalAnalysis
2025-07-30 19:33:01 +01:00
darashikoh
44f028731b Summary
The "Stop distance must be greater than 0" error was caused by:

Primary Issue: A recursive function call in GetValidATR() that was calling itself instead of using market.volatility
Secondary Issues: Insufficient validation and fallback mechanisms when market data is unavailable

Implementation Steps

Replace the GetValidATR function in EntrySystem.mqh with the fixed version
Add the enhanced validation to ensure stop distances are always valid
Implement debug logging to catch any remaining edge cases
Add startup validation for backtesting to ensure indicators are ready

Prevention
To prevent similar issues in the future:

Always validate indicator values before using them
Implement multiple fallback mechanisms for critical values
Add comprehensive logging during development
Test with various market conditions and data scenarios
Ensure sufficient historical data for indicator calculations

After implementing these fixes, the error should be resolved, and your EA will handle edge
2025-07-30 18:55:56 +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
32998d8c9a What Was Wrong:
Parameter Confusion: The function was receiving stop distance in price units (e.g., 0.00255 for EURUSD) but treating it as if it was already in points.
Double Conversion: The code was multiplying by point size when it shouldn't have, causing the calculation to be off by a factor of 10,000 or more on 5-digit brokers.

The Fix:
I've updated the lot size calculation to properly handle the conversion:
cpp// OLD (INCORRECT):
double ticks = (stop_points * point_size) / tick_size;  // Wrong!

// NEW (CORRECT):
double stop_points = stop_distance_price / point_size;   // Convert to points first
double stop_ticks = stop_points * point_to_tick_ratio;   // Then to ticks
Additional Improvements:

Safety Checks: Added validation to reject unreasonably high lot sizes (>1000 lots)
Enhanced Logging: More detailed debug output to diagnose issues
Dual Calculation Methods: Added a simplified calculation method for verification
Configuration Limits: Properly integrated min/max lot size limits f
2025-07-28 18:23:20 +01:00
darashikoh
a74c45d240 Summary of Fixes
I've identified and fixed the lot size calculation issue. The problem was in the formula used to calculate lot size from risk amount. Here's what was wrong and how it's fixed:
The Problem
The original calculation was producing lot sizes that were off by a factor of 100,000 (e.g., 1,315,295 lots instead of ~13 lots). This was due to an incorrect formula that wasn't properly using the tick value and tick size.
The Solution
The corrected formula now:

Uses tick value properly: The tick value represents the profit/loss in account currency for a 1 tick movement with 1 lot
Converts points to ticks: Since stop distance is in points, we convert it to ticks using point size and tick size
Calculates correctly: Lot Size = Risk Amount / (Stop Distance in Ticks × Tick Value)
2025-07-23 23:46:39 +01:00
darashikoh
3ae0f49654 The issue is in the lot size calculation in RiskManager.mqh. The calculation is producing an extremely large value (860,373 lots!) when it should be much smaller. 2025-07-22 18:24:37 +01:00
darashikoh
53c5b161e5 fix: resolve pointer syntax errors and missing return statements
- Replace arrow operator (->) with dereference syntax (*pointer).method() to fix parsing errors
- Add missing return true in CEntrySystem::ValidateSignal() 
- Fix missing parenthesis in PerformPeriodicTasks: if((*Utils).IsNewsTime())
- Affected modules: RiskMgr, TradeMgr, EntrySys, TechAnalysis, Dashboard, Utils

Resolves compilation errors related to pointer member access and control flow
2025-07-22 18:11:53 +01:00
darashikoh
ffae6bf4ff Fix: Resolve backtesting trade execution issues
Problem: EA was not opening trades during backtesting due to overly restrictive spread validation and position sizing calculation failures.
Changes Made:
1. EntrySystem.mqh - Improved Signal Validation

 Relaxed spread filter from fixed 10% ATR to dynamic 20-50% based on market conditions
 Added absolute maximum spread limit (5 pips for majors)
 Enhanced spread rejection logging with actual values

2. RiskManager.mqh - Fixed Position Sizing

 Added comprehensive logging throughout position size calculation
 Improved handling of minimum lot size requirements
 Added account balance validation before attempting trades
 Enhanced error messages for debugging
 Fixed lot size calculation for proper point value conversion
 Added validation for stop distance and risk amount inputs

3. ERMT_6.0.mq5 - Enhanced Configuration

 Increased default risk percent from 1% to 2.5% for better testing
 Increased max risk percent from 2% to 5%
 Adde
2025-07-22 17:33:44 +01:00
darashikoh
cd2696ae28 fix: resolve invalid pointer access error in EA initialization
- Replace dot operator (.) with arrow operator (->) for all pointer object access
- Add NULL checks before using Utils pointer in OnTick()
- Fix pointer syntax for modules: RiskMgr, TradeMgr, EntrySys, TechAnalysis, Dashboard, Utils
- Remove invalid Utils reference in OnDeinit() after object deletion

Fixes initialization crash at line 195 in ERMT_6.0.mq5 
File header renamed to ERMT_6.4.mq5
2025-07-22 17:07: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
darashikoh
644016f8e2 Moved ERMT_6.0, post first compile and debug to Advisors folder 2025-07-20 19:23:58 +01:00
darashikoh
fb5ce9481d Added v2.0 in the header to reflect function change from Compile 1 Debug 2025-07-20 17:37:34 +01:00
darashikoh
ac6089b898 Compile 1 Debug
Position Selection in MQL5: Unlike MQL4, MQL5 doesn't have PositionSelectByIndex(). You must use:

PositionGetSymbol(i) to get the symbol at index i
PositionSelect(symbol) to select a position by symbol
PositionSelectByTicket(ticket) to select by ticket


Commission Handling: In MQL5, commission is stored at the deal level, not the position level. To get the total commission for a position, you need to sum up the commissions from all deals related to that position.
Type Casting: When converting between numeric types, explicit casting is recommended to avoid warnings.
2025-07-20 17:22:58 +01:00
darashikoh
7aaae3f1a1 ERMT modules v6.0 2025-07-20 17:02:39 +01:00
darashikoh
aebe367724 new files added 2025-07-20 16:41:20 +01:00
darashikoh
4ab54de5f6 new files added 2025-07-08 23:34:12 +01:00
5a3d4c4d30 Initial commit 2025-06-09 08:52:01 +00:00