20 KiB
Configuration Recommendations for ERMT_PME EA
Exposing Hardcoded Variables for Better User Control
Analysis Date: 2025-11-04 EA Version: ERMT_PME v1.2 Purpose: Identify hardcoded variables that should be exposed as user inputs
Executive Summary
Current analysis reveals over 100 hardcoded variables that should be exposed as user inputs for better control and customization. These variables are organized into 13 functional groups with clear interaction patterns.
Key Findings
| Category | Hardcoded Variables | Priority |
|---|---|---|
| Risk Management | 7 | 🔴 HIGH |
| Profit Protection | 12 | 🔴 HIGH |
| Exit Management | 10 | 🟡 MEDIUM |
| Market Adaptation | 19 | 🟡 MEDIUM |
| Trailing Stops | 8 | 🟡 MEDIUM |
| Session Management | 7 | 🟢 LOW |
| Display Settings | 4 | 🟢 LOW |
Priority 1: Critical Risk Management Variables (URGENT)
Current State (Hardcoded)
File: ERMT_PME_1.2.mq5
// === RISK PROTECTION (Wider Tolerances) ===
double InpMaxLossPerTrade = 10; // Should be INPUT
double InpMaxDailyLoss = 20.0; // Should be INPUT
double InpMaxDrawdown = 30.0; // Should be INPUT
double InpMaxCorrelation = 0.85; // Should be INPUT
Recommended Change
// === RISK PROTECTION ===
input group "Risk Management"
input double InpMaxLossPerTrade = 5.0; // Max Loss Per Trade (%)
input double InpMaxDailyLoss = 10.0; // Max Daily Loss (%)
input double InpMaxDrawdown = 20.0; // Max Account Drawdown (%)
input double InpMaxCorrelation = 0.70; // Max Position Correlation
Why This Matters
Risk: Without user control, the EA can risk 10% per trade and 20% daily, which is:
- ❌ Excessive for most retail accounts
- ❌ Violates standard risk management (1-2% per trade)
- ❌ Can lead to rapid account depletion
Solution: Make these inputs so users can:
- ✅ Set conservative values (1-2% per trade)
- ✅ Adjust based on account size
- ✅ Match their risk tolerance
Trading Style Presets
| Style | Per Trade | Daily Loss | Drawdown | Use Case |
|---|---|---|---|---|
| Ultra Conservative | 0.5-1% | 2-3% | 5-10% | Retirement accounts |
| Conservative | 1-2% | 3-5% | 10-15% | Long-term growth |
| Balanced | 2-3% | 5-10% | 15-20% | Standard trading |
| Aggressive | 3-5% | 10-15% | 20-30% | Experienced traders |
| Very Aggressive | 5-10% | 15-20% | 30-40% | Prop traders |
Priority 2: Trailing Stop Configuration
Current State (Hardcoded)
File: ERMT_PME_1.2.mq5
// === TRAILING STOP CONFIGURATION (Wider) ===
input ENUM_TRAILING_METHOD InpTrailingMethod = TRAIL_ATR; // Already input
double InpTrailStart = 60; // Should be INPUT
double InpTrailDistance = 40; // Should be INPUT
double InpTrailStep = 15; // Should be INPUT
bool InpAdaptiveTrailing = true; // Should be INPUT
double InpLowVolatilityMultiplier = 0.8; // Should be INPUT
double InpHighVolatilityMultiplier = 1.5; // Should be INPUT
double InpVolatilityThreshold = 1.2; // Should be INPUT
Recommended Change
// === TRAILING STOP CONFIGURATION ===
input group "Trailing Stop Management"
input ENUM_TRAILING_METHOD InpTrailingMethod = TRAIL_ATR; // Trailing Method
input double InpTrailStart = 60; // Start Trailing After (pts)
input double InpTrailDistance = 40; // Trail Distance (pts)
input double InpTrailStep = 15; // Minimum Trail Step (pts)
input bool InpAdaptiveTrailing = true; // Enable Adaptive Trailing
input double InpLowVolatilityMultiplier = 0.8; // Low Vol Multiplier
input double InpHighVolatilityMultiplier = 1.5; // High Vol Multiplier
input double InpVolatilityThreshold = 1.2; // Volatility Threshold
Why This Matters
Issue: Fixed trailing parameters don't adapt to:
- Different instruments (stocks vs forex)
- Different timeframes (M5 vs H4)
- Different market conditions (trending vs ranging)
Solution: Expose these so users can:
- ✅ Set wider trails for longer timeframes
- ✅ Adjust for instrument volatility
- ✅ Fine-tune for their trading style
Trailing Style Presets
| Style | Trail Start | Trail Distance | Step | Adaptive | Use Case |
|---|---|---|---|---|---|
| Tight | 30pts | 20pts | 10pts | ✅ Yes | Scalping, M5 |
| Standard | 60pts | 40pts | 15pts | ✅ Yes | Intraday, H1 |
| Loose | 100pts | 60pts | 20pts | ✅ Yes | Swing, H4+ |
| Very Loose | 150pts | 80pts | 30pts | ✅ Yes | Position, Daily |
Priority 3: Partial Closure Strategy
Current State (Hardcoded)
File: ERMT_PME_1.2.mq5
// === PARTIAL CLOSE CONFIGURATION (Delayed) ===
bool InpPartialEnabled = true; // Should be INPUT
int InpPartialLevels = 4; // Should be INPUT
// Partial Close Levels (4 levels)
double InpPartial1_Trigger = 50; // Should be INPUT
double InpPartial1_Percent = 20; // Should be INPUT
double InpPartial2_Trigger = 100; // Should be INPUT
double InpPartial2_Percent = 25; // Should be INPUT
double InpPartial3_Trigger = 200; // Should be INPUT
double InpPartial3_Percent = 25; // Should be INPUT
double InpPartial4_Trigger = 400; // Should be INPUT
double InpPartial4_Percent = 15; // Should be INPUT
Recommended Change
// === PARTIAL CLOSE CONFIGURATION ===
input group "Partial Profit Taking"
input bool InpPartialEnabled = true; // Enable Partial Closes
input int InpPartialLevels = 4; // Number of Partial Levels (1-10)
// Level 1: Early Profit
input double InpPartial1_Trigger = 50; // Level 1 Trigger (pts)
input double InpPartial1_Percent = 20; // Level 1 Close (%)
// Level 2: Intermediate Profit
input double InpPartial2_Trigger = 100; // Level 2 Trigger (pts)
input double InpPartial2_Percent = 25; // Level 2 Close (%)
// Level 3: Strong Profit
input double InpPartial3_Trigger = 200; // Level 3 Trigger (pts)
input double InpPartial3_Percent = 25; // Level 3 Close (%)
// Level 4: Exceptional Profit
input double InpPartial4_Trigger = 400; // Level 4 Trigger (pts)
input double InpPartial4_Percent = 15; // Level 4 Close (%)
// Remaining = Runner (15% in this config)
Partial Strategy Comparison
Conservative: "Bank It Early"
InpPartialLevels = 3;
Level 1: 30pts → 40% closed (40% banked)
Level 2: 60pts → 30% closed (70% banked total)
Level 3: 100pts → 20% closed (90% banked total)
Runner: 10% remaining
Profile: Risk-averse, prefers guaranteed profits, smaller runners
Balanced: "Hybrid Approach" (Current)
InpPartialLevels = 4;
Level 1: 50pts → 20% closed (20% banked)
Level 2: 100pts → 25% closed (45% banked total)
Level 3: 200pts → 25% closed (70% banked total)
Level 4: 400pts → 15% closed (85% banked total)
Runner: 15% remaining
Profile: Balanced profit-taking, moderate runners
Aggressive: "Let It Run"
InpPartialLevels = 3;
Level 1: 100pts → 15% closed (15% banked)
Level 2: 200pts → 15% closed (30% banked total)
Level 3: 400pts → 20% closed (50% banked total)
Runner: 50% remaining
Profile: Trend-following, large runners, maximum profit capture
Scalping: "Quick Profits"
InpPartialLevels = 2;
Level 1: 10pts → 50% closed (50% banked)
Level 2: 20pts → 30% closed (80% banked total)
Runner: 20% remaining
Profile: Fast-paced, small targets, high turnover
Priority 4: Dynamic Stop Management
Current State (Hardcoded)
File: ERMT_PME_1.2.mq5
// === DYNAMIC STOP MANAGEMENT ===
bool InpDynamicStops = true; // Should be INPUT
bool InpTightenOnProfit = true; // Should be INPUT
double InpTightenThreshold = 75; // Should be INPUT
bool InpProtectProfits = true; // Should be INPUT
double InpProtectionThreshold = 100; // Should be INPUT
Recommended Change
// === DYNAMIC STOP MANAGEMENT ===
input group "Dynamic Stop Adjustment"
input bool InpDynamicStops = true; // Enable Dynamic Stops
input bool InpTightenOnProfit = true; // Tighten Stops in Profit
input double InpTightenThreshold = 75; // Tighten After (pts)
input bool InpProtectProfits = true; // Enable Profit Protection
input double InpProtectionThreshold = 100; // Protect After (pts)
How This Works
Position Lifecycle with Dynamic Stops:
Entry → 40pts → PROTECTION Phase (10pts lock)
→ 75pts → TIGHTEN threshold
→ Stops begin tightening progressively
→ 100pts → PROTECTION threshold
→ Profit protection activates
→ 200pts → RUNNER Phase (100pts lock)
Without Dynamic Stops:
- Static stop at entry -50pts
- No adaptation to profit development
- Risk: Full retracement from 150pts → Stop hit at -50pts
With Dynamic Stops:
- Stop moves with profit
- At 150pts: Stop at +50pts minimum (phase lock)
- Risk: Limited retracement, worst case +50pts exit
Configuration Groups & Interactions
Group A: Breakeven System (DISABLED - Replaced by Phase Locks)
#if USE_BREAKEVEN_SYSTEM
input bool InpBreakevenEnabled = true;
input double InpBreakevenTrigger = 40;
input double InpBreakevenOffset = 8;
input bool InpMultiLevelBE = true;
#else
bool InpBreakevenEnabled = false; // Currently DISABLED
#endif
Status: ❌ Disabled in favor of phase-based profit locking Reason: Conflicts with phase locks at 40pts trigger point
Group B: Phase-Based Profit Locking (PRIMARY SYSTEM)
input group "Phase-Based Profit Locking"
input bool InpUsePhaseProfitLocks = true; // ✅ Already exposed
input double InpPhaseLockBreathingRoom = 50; // ✅ Already exposed
input bool InpMaintainLockOnRetreat = true; // ✅ Already exposed
input double InpRetreatLockMultiplier = 1.2; // ✅ Already exposed
// Phase Minimum Locks
input double InpPhase1MinLock = 10; // ✅ Already exposed
input double InpPhase2MinLock = 25; // ✅ Already exposed
input double InpPhase3MinLock = 50; // ✅ Already exposed
input double InpPhase4MinLock = 100; // ✅ Already exposed
input double InpPhase5MinLock = 200; // ✅ Already exposed
Status: ✅ Well-configured, already exposed as inputs Note: These are the primary profit protection system
Group C: Session-Based Adjustments
// === SESSION-BASED ADJUSTMENTS ===
bool InpSessionBasedManagement = true; // Should be INPUT
double InpAsianTrailMultiplier = 1.2; // Should be INPUT
double InpAsianPartialMultiplier = 1.5; // Should be INPUT
double InpLondonTrailMultiplier = 1.0; // Should be INPUT
double InpLondonPartialMultiplier = 1.0; // Should be INPUT
double InpNewYorkTrailMultiplier = 0.9; // Should be INPUT
double InpNewYorkPartialMultiplier = 0.8; // Should be INPUT
Recommended Change
// === SESSION-BASED ADJUSTMENTS ===
input group "Session Management"
input bool InpSessionBasedManagement = true; // Enable Session Adaptation
// Asian Session (Low volatility, wider stops)
input double InpAsianTrailMultiplier = 1.2; // Asian Trail Multiplier
input double InpAsianPartialMultiplier = 1.5; // Asian Partial Multiplier
// London Session (High volatility, standard)
input double InpLondonTrailMultiplier = 1.0; // London Trail Multiplier
input double InpLondonPartialMultiplier = 1.0; // London Partial Multiplier
// New York Session (High volatility, tighter)
input double InpNewYorkTrailMultiplier = 0.9; // NY Trail Multiplier
input double InpNewYorkPartialMultiplier = 0.8; // NY Partial Multiplier
Session Profiles
| Session | Characteristics | Trail Mult. | Partial Mult. | Strategy |
|---|---|---|---|---|
| Asian | Low volatility, wide ranges | 1.2-1.5× | 1.3-1.5× | Wider stops, later partials |
| London | High volatility, trending | 1.0× | 1.0× | Standard settings |
| NY | High volatility, reversals | 0.8-0.9× | 0.8-0.9× | Tighter stops, earlier partials |
| Overlap | Highest volatility | 0.7-0.8× | 0.7-0.8× | Very tight, quick profits |
Implementation Priority Roadmap
Phase 1: Critical Variables (Next Release)
Must Have:
- ✅ Risk limits (Max loss per trade, daily, drawdown)
- ✅ Trailing parameters (Start, distance, step)
- ✅ Partial closure settings (Triggers, percentages)
- ✅ Dynamic stop thresholds
Estimated Work: 2-3 hours Impact: HIGH - Gives users essential control
Phase 2: Market Adaptation (Following Release)
Should Have:
- ✅ Session multipliers
- ✅ Volatility adjustments
- ✅ Momentum thresholds
- ✅ Time filters
Estimated Work: 3-4 hours Impact: MEDIUM - Improves adaptability
Phase 3: Advanced Features (Future)
Nice to Have:
- ✅ Technical exit signals
- ✅ Volume analysis parameters
- ✅ Support/resistance buffers
- ✅ Advanced protection mechanisms
Estimated Work: 4-5 hours Impact: LOW - For power users
Preset Configuration System
Recommended Implementation
//+------------------------------------------------------------------+
//| Trading Style Presets |
//+------------------------------------------------------------------+
enum ENUM_TRADING_STYLE
{
STYLE_ULTRA_CONSERVATIVE, // Ultra Conservative (0.5-1% risk)
STYLE_CONSERVATIVE, // Conservative (1-2% risk)
STYLE_BALANCED, // Balanced (2-3% risk)
STYLE_AGGRESSIVE, // Aggressive (3-5% risk)
STYLE_VERY_AGGRESSIVE, // Very Aggressive (5-10% risk)
STYLE_CUSTOM // Custom (user-defined)
};
input group "=== Quick Setup ==="
input ENUM_TRADING_STYLE InpTradingStyle = STYLE_BALANCED; // Select Trading Style
input bool InpUsePreset = true; // Use Preset Configuration
Preset Values Table
| Parameter | Ultra Cons. | Conserv. | Balanced | Aggress. | Very Aggr. |
|---|---|---|---|---|---|
| Max Loss/Trade | 0.5% | 1% | 3% | 5% | 10% |
| Max Daily Loss | 2% | 3% | 10% | 15% | 20% |
| Max Drawdown | 5% | 10% | 20% | 30% | 40% |
| Trail Start | 30pts | 40pts | 60pts | 80pts | 100pts |
| Trail Distance | 20pts | 30pts | 40pts | 50pts | 60pts |
| Partial 1 Trigger | 30pts | 40pts | 50pts | 80pts | 100pts |
| Partial 1 % | 40% | 30% | 20% | 15% | 10% |
| Runner % | 10% | 15% | 15% | 30% | 50% |
| Phase 1 Lock | 15pts | 12pts | 10pts | 8pts | 5pts |
| Breathing Room | 30% | 40% | 50% | 60% | 70% |
Code Implementation Example
void ApplyTradingStylePreset()
{
if(!InpUsePreset) return; // User wants custom settings
switch(InpTradingStyle)
{
case STYLE_ULTRA_CONSERVATIVE:
g_config.max_loss_per_trade = 0.5;
g_config.max_daily_loss = 2.0;
g_config.max_drawdown = 5.0;
g_config.trail_start = 30;
g_config.trail_distance = 20;
g_config.partial_1_trigger = 30;
g_config.partial_1_percent = 40;
g_config.runner_percentage = 10;
g_config.phase1_min_lock = 15;
g_config.breathing_room = 30;
break;
case STYLE_CONSERVATIVE:
// ... conservative settings
break;
case STYLE_BALANCED:
// ... balanced settings (current defaults)
break;
case STYLE_AGGRESSIVE:
// ... aggressive settings
break;
case STYLE_VERY_AGGRESSIVE:
// ... very aggressive settings
break;
case STYLE_CUSTOM:
// Use user-defined input parameters
break;
}
if(g_utils != NULL)
{
g_utils.Log(StringFormat("Applied %s preset configuration",
EnumToString(InpTradingStyle)), LOG_INFO);
}
}
Validation & Safety
Input Validation Requirements
bool ValidateInputParameters()
{
bool valid = true;
// Risk limits
if(InpMaxLossPerTrade < 0.1 || InpMaxLossPerTrade > 20)
{
Print("ERROR: Max loss per trade must be between 0.1% and 20%");
valid = false;
}
// Phase triggers must be ascending
if(InpPhase1Trigger >= InpPhase2Trigger ||
InpPhase2Trigger >= InpPhase3Trigger ||
InpPhase3Trigger >= InpPhase4Trigger ||
InpPhase4Trigger >= InpPhase5Trigger)
{
Print("ERROR: Phase triggers must be in ascending order");
valid = false;
}
// Partial percentages must not exceed 100% total
double total_partial = InpPartial1_Percent + InpPartial2_Percent +
InpPartial3_Percent + InpPartial4_Percent;
if(total_partial > 95) // Allow max 95% closed, 5% min runner
{
Print("ERROR: Total partial closes exceed 95%");
valid = false;
}
// Trail distance must be positive
if(InpTrailDistance <= 0)
{
Print("ERROR: Trail distance must be positive");
valid = false;
}
return valid;
}
Warning System
void WarnAboutAggressiveSettings()
{
string warnings = "";
if(InpMaxLossPerTrade > 5)
warnings += "⚠️ WARNING: Max loss per trade exceeds 5% (very aggressive)\n";
if(InpMaxDailyLoss > 15)
warnings += "⚠️ WARNING: Max daily loss exceeds 15% (very aggressive)\n";
if(InpRunnerPercentage > 40)
warnings += "⚠️ WARNING: Runner percentage exceeds 40% (high risk)\n";
if(InpPhaseLockBreathingRoom > 70)
warnings += "⚠️ WARNING: Breathing room exceeds 70% (loose protection)\n";
if(warnings != "")
{
Print("=== AGGRESSIVE SETTINGS DETECTED ===");
Print(warnings);
Print("Consider using STYLE_BALANCED for safer trading");
}
}
Summary & Next Steps
Current Status
- ✅ Phase-based profit locking: Well-configured (already inputs)
- ⚠️ Risk management: Needs urgent attention (hardcoded at risky levels)
- ⚠️ Trailing stops: Needs configuration (fixed for all instruments)
- ⚠️ Partial closures: Needs flexibility (one-size-fits-all)
Recommended Actions
Immediate (Before Next Use):
- Expose risk management variables as inputs
- Add input validation and warnings
- Document recommended settings for different account sizes
Short-Term (Next Update):
- Expose trailing and partial configuration
- Implement preset system (Conservative/Balanced/Aggressive)
- Add session-based adjustments
Long-Term (Future Enhancements):
- Add configuration save/load functionality
- Implement A/B testing framework
- Create performance tracking by configuration
Expected Benefits
For Users:
- ✅ Better risk control (1-2% per trade instead of 10%)
- ✅ Customization for trading style
- ✅ Adaptation to different instruments/timeframes
- ✅ Quick setup with presets
For EA Performance:
- ✅ Reduced drawdowns (proper risk sizing)
- ✅ Better profit capture (optimized partials)
- ✅ Improved adaptability (session/volatility adjustments)
- ✅ Higher consistency (matched to market conditions)
Analysis Complete: 2025-11-04 Priority: 🔴 HIGH - Implement Phase 1 variables immediately Impact: Critical for safe operation and user control