I need an experienced MQL4 developer to create a sophisticated multi-timeframe divergence trading EA based on an existing MQL4 code. The EA should implement a smart divergence detection system with trendline filtering and martingale functionality.
### **Core Trading Logic Requirements**
#### **1. DIVERGENCE SIGNAL DETECTION**
- **Multi-Timeframe Analysis**: M1, M5, M15 with help of the custom indicators
- **Signal Types**:
- **Bullish Regular Divergence**
- **Bullish Hidden Divergence**
- **Bearish Regular Divergence**
- **Bearish Hidden Divergence**
Lot sizes for EACH divergence and EACH Timeframe:
M1 Bullish Regular Divergence Lotsize x.xx
M1 Bullish Hidden Divergence Lotsize x.xx
M1 Bearish Regular Divergence Lotsize x.xx
M1 Bearish Hidden Divergence Lotsize x.xx
the same for M5 and M15
Example:
M1 Bullish Regular Divergence 0.02
M1 Bullish Hidden Divergence 0.0
M5 Bullish Regular Divergence 0.04
M5 Bullish Hidden Divergence 0.02 and so on
Case 1:
Divergence M1 bullish regular signal comes: buy trade with 0.02 lots is placed, divergence M1 bullish hidden signal comes, no trade
Case 2:
Divergence M1 bullish hidden signal comes: no trade, divergence M5 buy regular signal comes, buy trade with 0.04 is placed
#### **2. TRENDLINE FILTERING (true(false)**
- **If trendline filter is set to true trades ONLY allowed when price is:
- **Below Lower Trendline** for BUY signals
- **Above Upper Trendline** for SELL signals
- **If trendline filter is set to false, all trades allowed according to the indicators signals
#### **3. MARTINGALE SYSTEM**
- **Levels**: Configurable additional trades for sell and buy separately (1 initial + X martingale levels)
- **Distance, 2 options**: Fixed pip distance from last trade alone OR entries at signals of indicators AND pip distance
- **Lot Increase**: Percentage-based lot size increase per level
- **Max Levels**: Strict limit on total trades per direction
#### **4. RISK MANAGEMENT**
- **Position Limits**:
- Max total open trades
- Max long trades
- Max short trades
- **Stop Loss & Take Profit**: Fixed pip distances
- **Trailing Stop**: Activated after specified profit in pips
- **Spread Filter**: Maximum allowed spread
### **Technical Specifications**
#### **INDICATOR INTEGRATION**
- **Custom Indicators provided by the client**:
- "Divergence 3fold Lux 2fold LOOKBACK" (M1)
- "Divergence 3fold Lux 2fold M5 LOOKBACK" (M5)
- "Divergence 3fold Lux 2fold M15 LOOKBACK" (M15)
They have parameters (Lookback_Period, IFX_HMA_period and Divergence_pivots_period (M15: Divergence_M15_pivots_period)) which need to be represented
in the EA aswell.
#### **TRADING CONDITIONS**
- **Time Filter**: Specific trading hours (configurable)
- **Bar Delay**: Minimum bars between new normal trades
- **Lot Sizes**: Separate configuration for each signal type/timeframe
- **Magic Number**: Unique identifier for EA orders
### **Key Behavioral Rules**
#### **NORMAL TRADING**
- Only ONE normal trade opened at a time
- Strict trendline enforcement when enabled
#### **MARTINGALE BEHAVIOR**
- Martingale ONLY activates when normal trade running
- Additional entries at fixed distance from last trade
- Progressive lot size increase
- Strict level limits
#### **TRADE COMMENTS**
. Trades receive comments including name of EA and direction and with trendline/without trendline for initial trades and for martingale trades name of EA and direction and martingale
### **Development Deliverables**
1. **Complete MQL4 EA** with all specified functionality
2. **Proper error handling** and logging
3. **Parameter optimization** capabilities
4. **Backtesting compatibility**
5. **Clean, commented code**
### **Required Skills**
- Advanced MQL4 programming
- Experience with custom indicators integration
- Martingale/position averaging systems
- Trendline object handling
- Multi-timeframe analysis
### **Additional Notes**
- Code must be efficient for real-time trading
- Proper order management and modification
- Comprehensive print logging for debugging
- All parameters externally configurable
**Please provide examples of similar EAs you've developed and your estimated timeline for this project.**