iardavan wrote: Tue Oct 07, 2025 10:25 am
Greetings and respect. For a long time, I've been struggling with the issue that only some experts work properly on the chart.
I want to know if you've figured out the cause of this problem. Is it due to the experts themselves, MetaTrader's graphical settings, or something else?
The problem I've discovered through my testing is that any Symbol Changer refuses to work correctly with any EA on the chart. Why?
### Understanding the Issue
In MetaTrader 4 (MT4) and MetaTrader 5 (MT5), a "Symbol Changer" is typically a custom indicator (often a panel with clickable buttons for symbols like EURUSD, GBPJPY, etc.) that allows quick switching of the chart's current trading symbol without opening new windows. While convenient, it can disrupt Expert Advisors (EAs)—automated trading scripts—due to how MT4/MT5 handles chart events and symbol changes. This is a common complaint in trading communities, stemming from core platform mechanics rather than a bug in your setup.
### Why EAs "Refuse to Work" with a Symbol Changer
EAs rely on stable chart data and uninterrupted event processing to function correctly. A Symbol Changer interferes in these key ways:
1. **Chart Symbol Changes Trigger EA Deinitialization**:
- When the Symbol Changer switches the chart's symbol (e.g., from EURUSD to GBPUSD), MT4/MT5 treats this as a major chart reconfiguration. The platform automatically calls the EA's `OnDeinit()` function (or `deinit()` in MT4), unloading the EA from the chart.
- Upon switching back, the EA must reinitialise via `OnInit()` (or `init()` in MT4). This process can fail or take time, especially if the EA loads complex indicators, buffers, or market data. During this window, the EA appears "inactive" (no smiley face in MT4, or no trading activity in MT5).
- **Impact**: EAs miss ticks, signals, or orders. If the EA doesn't handle reinitialization gracefully (e.g., via error checking in `OnInit()`), it may enter a "refusal" state, logging errors like "invalid symbol" or "initialisation failed."
2. **Event Handling Conflicts (OnChartEvent Interference)**:
- Symbol Changers often use `OnChartEvent()` to capture mouse clicks on buttons, blocking or overriding other chart events (e.g., ticks, timer events, or custom EA events).
- EAs depend on these events for real-time decisions (e.g., `OnTick()` for price updates). If the changer has high Z-order priority (to stay on top), it "steals" focus, causing EAs to ignore incoming data or fail to execute trades.
- In MT5, this is exacerbated by multi-threaded event processing, where the changer's panel can delay EA callbacks.
3. **Resource and Data Loading Overload**:
- Switching symbols forces MT4/MT5 to reload historical data, indicators, and objects for the new symbol. If your EA uses heavy computations (e.g., multiple timeframes or custom buffers), this can exceed platform limits, causing timeouts or crashes.
- Symbol mismatches (e.g., broker-specific suffixes like EURUSD.s vs. EURUSD) can also confuse the EA during reloads, leading to "no quotes" errors.
4. **Platform Differences**:
- **MT4**: More prone to full EA stops during symbol changes due to its single-threaded nature. Common with older changers lacking MT4-specific fixes.
- **MT5**: Handles multi-symbol better but still deinitializes EAs on changes. Newer MT5 builds (post-2023) have improved stability, but custom changers may not be updated.
This isn't unique to your EAs—it's a widespread issue discussed in forums, where users report changers causing "disappearing buttons," multiple chart opens, or stalled EAs.
### How to Fix or Work Around It
To resolve this, prioritise stability over convenience. Here's a step-by-step guide:
1. **Remove or Replace the Symbol Changer**:
- Temporarily disable the changer (right-click chart > Indicators List > Remove) and test your EA. If it works, that's the culprit.
- Switch to a non-intrusive alternative:
- **Built-in MT Method**: Right-click Market Watch > Symbols (Ctrl+U) for quick selection without indicators.
- **Recommended Free Tools**:
- For MT5: "SetSymbol" utility (download from trusted sources like Forex Factory threads).
- For MT4: "Multi-Symbol Dashboard" indicators that don't use aggressive event handling.
- Avoid changers with "sync all charts" features, as they amplify deinitialization across windows.
2. **Modify Your EA for Resilience**:
- Edit the EA code (if you have access) to handle symbol changes:
- In `OnInit()`: Add checks like `if(!SymbolSelect(_Symbol, true)) return INIT_FAILED;`.
- Use `OnDeinit()` to save state (e.g., open positions) and reload in `OnInit()`.
- Enable "Allow DLL imports" and "Allow live trading" in EA properties.
- Test in Strategy Tester with symbol switches to simulate issues.
3. **Platform Tweaks**:
- **Restart Terminal**: After symbol changes, close/reopen charts to force full EA reloads.
- **Update MT4/MT5**: Ensure you're on the latest build (Help > Check for Updates) for better event handling.
- **Separate Charts**: Run EAs on dedicated charts without changers. Use multi-chart layouts (File > Profiles) for monitoring.
- **Broker Check**: Confirm symbols match your account (e.g., no suffix mismatches). Use Tools > Options > Charts > Max bars in chart (set high, like 500,000) for smoother data loads.
4. **Debugging Steps**:
- Enable EA logging: In the Journal/Experts tab, look for errors like "EA unloaded" or "OnInit failed."
- Test on Demo: Replicate on a fresh demo account to rule out account-specific issues.
- If persistent, share your EA/changer .ex4/.ex5 files on forums like MQL5.com for community debugging.
By isolating the changer, your EAs should run smoothly. If this is a specific changer, check its thread for EA-compatibility patches—many authors release fixes. If you provide more details (e.g., EA name or error logs), I can refine this further!