Summary: Discover the undocumented MT4 behavior where the platform automatically adds symbols to Market Watch during profit calculations. Practical guide to understanding and working around this feature.




Let me tell you about something that drove me nuts for three days before I figured out what was going on. I had an EA that was supposed to scan exactly five currency pairs in Market Watch and trade based on their signals. But when I checked the logs, it was scanning eight pairs. Then twelve. Then the whole damn list.

I was sure my code was the problem. Rewrote the symbol enumeration three times. Checked the loop logic. Added print statements everywhere. Nothing made sense.

Then I stumbled onto an old MQL5 forum thread where a developer named stringo from MetaQuotes dropped a bombshell: "This is not a bug. It is specifically programmed behaviour" . He was responding to another trader who had the exact same problem.

Here's what's actually happening behind the scenes. The MQL4 documentation doesn't mention this anywhere. But when your EA calculates profit or margin requirements for open positions, MT4 automatically adds the symbols involved in those calculations to Market Watch. Even if you never added them yourself. The official line from MetaQuotes is that "implicit inclusion of pairs that participate in calculation of profits and margin requirements" is an intended design choice .

Why This Matters for Your EA



Let me walk through a real scenario. Say your EA has positions open on AUDCHF and NZDUSD. Your code loops through SymbolsTotal() to scan Market Watch for trade signals. Before you know it, your EA is scanning 50 pairs instead of the 5 you actually want to watch. This can slow down execution, mess with your strategy logic, and cause unexpected behavior.

The most frustrating part? There's no official function to check if a symbol was hidden versus explicitly added. According to the forum discussion, MetaQuotes acknowledged this limitation but never added a fix .

My Workaround



After banging my head against this for way too long, here's what I landed on:

  • <strong>Store your target symbols in an external list.</strong> Don't rely on SymbolsTotal() to tell you what's in Market Watch. Use a CSV file or input parameters with a fixed list of symbols.


  • <strong>Check symbol existence with SymbolSelect() before scanning.</strong> This lets you explicitly add symbols you want without relying on auto-add behavior.


  • <strong>Periodically clean Market Watch.</strong> I run a cleanup routine that removes any symbol that's not in my approved list AND has no open positions. The SymbolSelect(symbol, false) function is your friend here.


  • <strong>Track hidden status with custom variables.</strong> Since MT4 doesn't track it natively, I maintain an array of symbols I've intentionally added and compare against it.


  • Here's the code snippet that saved my sanity:

    ``mql4
    // Instead of blindly looping through SymbolTotal()
    string targetSymbols[5] = {"EURUSD", "GBPUSD", "USDJPY", "AUDUSD", "USDCAD"};

    for(int i = 0; i < ArraySize(targetSymbols); i++) {
    if(SymbolSelect(targetSymbols[i], true)) {
    // Symbol is now in Market Watch, scan it
    double bid = MarketInfo(targetSymbols[i], MODE_BID);
    // ... your trading logic
    }
    }
    ``

    Reference



  • MQL5 Forum Discussion on Symbol List Behavior: mql5.com/en/forum/400284/page6


  • 本文首发于FXEAR.com,原创内容,未经授权禁止转载