Skip to content

Runtime error

4301 ERR_MARKET_UNKNOWN_SYMBOL

Unknown symbol: the broker has no symbol with that name

What it means

A symbol function was given a name that does not exist on this trade server. Brokers name the same instrument differently, with suffixes or prefixes for account types ("EURUSD.m", "EURUSDm", "EURUSD.pro") or other names for metals and indices.

Common causes

  • Symbol names hard-coded in the EA ("EURUSD", "XAUUSD", "US30").
  • A multi-symbol input list written for one broker and used on another.
  • A typo or a stray space in a symbol list input.

A real scenario

A correlation EA reads EURUSD and GBPUSD while trading the chart symbol. On a broker whose symbols end in ".m", SymbolInfoDouble("GBPUSD", SYMBOL_BID) returns 0 with error 4301, and the EA computes its correlation from zeros. Resolving each name against the broker's list at start fixed it and stops the EA if a symbol is missing.

How to fix it

  1. Prefer _Symbol and inputs over hard-coded names.
  2. At start, resolve each name: check SYMBOL_EXIST, else look for the broker's symbol that starts with it.
  3. Stop with a clear message if a symbol cannot be found, instead of trading on zeros.

Fixed MQL5 code

MQL5
string ResolveSymbol(const string base)
{
   if((bool)SymbolInfoInteger(base, SYMBOL_EXIST))
      return base;
   for(int i = 0; i < SymbolsTotal(false); i++)        // false = every symbol on the server
   {
      string name = SymbolName(i, false);
      if(StringFind(name, base) == 0)                   // "EURUSD.m", "EURUSDm", "EURUSD.pro" ...
         return name;
   }
   return "";                                          // not on this server: stop with a message
}

A focused example for MetaTrader 5: adapt names, magic number and limits to your EA, and test it on a demo account first.

EA Doctor rules that catch it

  • MediumHard-coded symbol nameThe code names a symbol such as "EURUSD" or "XAUUSD", which breaks on brokers that use another name or a suffix.

Sources

Get your EA fixed

Still failing with 4301? Send us the EA and the journal lines: we find the cause in the code and fix it. Or check it yourself first with the EA Doctor.