7.9 KiB
D-Basket EA - Quick Start Guide
Installation
1. Copy Files to MT5
Copy the entire MQL5 folder structure to your MetaTrader 5 data directory:
Windows: C:\Users\[YourName]\AppData\Roaming\MetaQuotes\Terminal\[Instance]\MQL5\
File Structure:
MQL5/
├── Experts/
│ └── DBasketEA.mq5
└── Include/
└── DBasket/
├── DBasket_Defines.mqh
├── DBasket_Structures.mqh
├── DBasket_Logger.mqh
├── DBasket_CorrelationEngine.mqh
├── DBasket_SignalEngine.mqh
├── DBasket_TradeWrapper.mqh
├── DBasket_PositionManager.mqh
└── DBasket_RiskManager.mqh
2. Compile in MetaEditor
- Open MetaEditor (F4 in MT5)
- Navigate to
Experts/DBasketEA.mq5 - Click Compile (F7)
- Verify: 0 errors, 0 warnings ✅
3. Attach to Chart
- Open AUDCAD chart (any timeframe, M15 or H1 recommended)
- Drag
DBasketEAfrom Navigator onto chart - Configure parameters (see below)
- Enable AutoTrading (Ctrl+E)
Essential Parameters
Minimum Configuration
Symbol Suffix: [leave blank or enter broker suffix like ".m"]
Entry Z-Score: 2.5
Exit Z-Score: 0.5
Min Correlation: 0.75
Fixed Lot Size: 0.01
Max Drawdown: 15.0
Daily Loss Limit: 100.0
Critical Settings
⚠️ MUST CONFIGURE
- Symbol Suffix: If your broker uses suffixes (e.g., AUDCAD.m), enter it here
- Magic Number: Change if running multiple EAs
- Max Drawdown: Set according to your risk tolerance
Pre-Flight Checklist
Before running the EA, verify:
- ✅ Hedging account (not netting) - EA will fail on netting accounts
- ✅ All 3 symbols available: AUDCAD, NZDCAD, AUDNZD
- ✅ AutoTrading enabled in MT5 (Ctrl+E)
- ✅ EA allowed to trade (Tools → Options → Expert Advisors)
- ✅ Sufficient margin for 3 positions
- ✅ Spreads reasonable (< 3 pips per symbol)
First Backtest
Strategy Tester Setup
- Symbol: AUDCAD
- Timeframe: M15 or H1
- Period: 2023.01.01 - 2025.01.01 (1 year minimum)
- Model: Every tick based on real ticks
- Deposit: 10,000 (or your account size)
- Leverage: 1:100 (or your broker's leverage)
Expected Results
- Trade Count: 50-200 baskets per year (depends on parameters)
- Win Rate: Target > 65%
- Profit Factor: Target > 1.3
- Max Drawdown: Should stay below configured limit
Visual Mode
Enable visual mode to see:
- When baskets open/close
- Z-score values in real-time
- Circuit breaker status
- Performance metrics on chart
Understanding the Display
The EA shows real-time metrics on the chart:
=== D-Basket EA Risk Monitor ===
Status: NORMAL
Net P/L: $125.50 (1.3%)
Daily P/L: $45.20
Drawdown: 3.2% (Max: 5.8%)
Baskets: 12 | Win Rate: 75.0%
Consecutive Losses: 0
Status Indicators
- NORMAL: Trading allowed, all systems operational
- WARNING: Risk levels elevated, warnings logged
- HALTED: Circuit breaker tripped, trading stopped
Common Scenarios
Scenario 1: EA Opens a Basket
What happens:
- Z-score exceeds entry threshold (e.g., -2.7)
- All 8 filters pass
- EA opens 3 positions simultaneously:
- AUDNZD: BUY 0.01 lots
- AUDCAD: SELL 0.01 lots
- NZDCAD: BUY 0.01 lots
What to check:
- All 3 positions opened successfully
- Magic number matches on all positions
- Comment shows basket ID (e.g., "DBasket_1")
Scenario 2: EA Closes a Basket
What happens:
- Z-score returns to exit threshold (e.g., -0.3)
- EA closes all 3 positions
- P&L is recorded and metrics updated
What to check:
- All 3 positions closed
- Win/loss recorded correctly
- Metrics updated on chart
Scenario 3: Circuit Breaker Trips
What happens:
- Drawdown reaches 15% (or configured limit)
- EA status changes to "HALTED"
- No new baskets will open
- Existing basket may be closed (emergency exit)
What to do:
- Review what caused the drawdown
- Check if parameters need adjustment
- Manually reset circuit breaker if appropriate
- Consider reducing risk parameters
Troubleshooting
EA Not Opening Trades
Check:
- Circuit breaker status (should be NORMAL)
- Current z-score (use visual mode to see)
- Correlation level (must be > min threshold)
- Spreads (must be < max threshold)
- Trading hours (must be within configured window)
- Logs for filter rejection reasons
Partial Basket Opened
What happened:
- One or two legs opened, but not all three
- EA automatically rolled back (closed opened positions)
Check:
- Logs for error messages
- Broker execution quality
- Margin availability
- Symbol tradability
High Drawdown
Actions:
- Stop EA immediately
- Review recent trades
- Check if correlation broke down
- Consider more conservative parameters:
- Increase entry z-score (e.g., 3.0)
- Increase min correlation (e.g., 0.80)
- Reduce lot size
- Lower max drawdown limit
Parameter Optimization
Optimization Ranges
Use Strategy Tester's optimization feature:
| Parameter | Min | Max | Step |
|---|---|---|---|
| Entry Z-Score | 2.0 | 3.5 | 0.25 |
| Exit Z-Score | 0.3 | 1.0 | 0.1 |
| Min Correlation | 0.70 | 0.85 | 0.05 |
| Lookback Period | 150 | 350 | 50 |
Optimization Criterion
The EA's OnTester() function returns a custom score:
score = (profit / drawdown) × profit_factor × win_rate
This prioritizes:
- Risk-adjusted returns
- Consistent profitability
- High win rate
Risk Management
Circuit Breaker Triggers
| Condition | Warning | Trip |
|---|---|---|
| Drawdown | 8% | 15% |
| Daily Loss | - | $100 or 5% |
| Margin Level | 500% | 200% |
| Consecutive Losses | - | 6 |
Manual Intervention
When to intervene:
- Circuit breaker trips repeatedly
- Win rate drops below 50%
- Correlation between pairs breaks down
- Broker execution quality degrades
How to intervene:
- Stop EA
- Close any open baskets manually
- Review parameters
- Restart with adjusted settings
Best Practices
1. Start Small
- Begin with minimum lot size (0.01)
- Test on demo account for 1+ month
- Gradually increase lot size after validation
2. Monitor Daily
- Check circuit breaker status
- Review daily P&L
- Verify correlation remains stable
- Check for error logs
3. Regular Optimization
- Reoptimize parameters quarterly
- Use walk-forward analysis
- Compare live results to backtest
4. Broker Selection
- Choose broker with tight spreads
- Ensure hedging is allowed
- Verify fast execution (< 500ms)
- Check commission structure
Support
Log Files
Enable file logging for detailed records:
Log Level: INFO (or DEBUG for troubleshooting)
Log to File: true
Logs saved to: MQL5/Files/DBasket_[date].log
Documentation
- README.md - User guide and installation
- TECHNICAL_DOCUMENTATION.md - Architecture and diagrams
- DEVELOPMENT_SUMMARY.md - Project overview
Common Questions
Q: Can I run this on a netting account?
A: No, hedging account is mandatory. The EA will fail initialization on netting accounts.
Q: How many trades per week?
A: Typically 2-10 signals per week at default parameters. Depends on market volatility.
Q: What's the minimum account size?
A: Recommended minimum $1,000 for 0.01 lot size with proper risk management.
Q: Can I run multiple instances?
A: Yes, but use different magic numbers for each instance.
Next Steps
- ✅ Install and compile EA
- ⏳ Run backtest on 1 year of data
- ⏳ Optimize parameters
- ⏳ Deploy to demo account
- ⏳ Monitor for 1+ month
- ⏳ Consider live deployment
📄 License & Copyright
Copyright © 2025 Dineth Pramodya
Website: www.dineth.lk
All rights reserved.
Last Updated: December 28, 2025
Developed by: Dineth Pramodya
For detailed technical information, see TECHNICAL_DOCUMENTATION.md