EA stops opening trades after broker migration have symbol naming issue?

 
Hi everyone,

Moved my EA from a demo to OANDA live account and it stopped opening trades completely. No errors in the journal, just silence. Figured out the problem. It was my EA had "EURUSD" hardcoded but on OANDA the symbol is "EUR_USD" with an underscore.

Is there a universal way to handle this? I'm thinking of using SymbolsTotal() and SymbolName() to search for a matching pair dynamically, but feels clunky. How do you guys handle symbol name differences across brokers in your EAs?
 
Tonesels:
Hi everyone,

Moved my EA from a demo to OANDA live account and it stopped opening trades completely. No errors in the journal, just silence. Figured out the problem. It was my EA had "EURUSD" hardcoded but on OANDA the symbol is "EUR_USD" with an underscore.

Is there a universal way to handle this? I'm thinking of using SymbolsTotal() and SymbolName() to search for a matching pair dynamically, but feels clunky. How do you guys handle symbol name differences across brokers in your EAs?
_Symbol
Documentation on MQL5: _Symbol / Predefined Variables
Documentation on MQL5: _Symbol / Predefined Variables
  • www.mql5.com
The _Symbol variable contains the symbol name of the current chart. You may also use the Symbol() function...
 
ToneselsIs there a universal way to handle this?
  1. You said it just stopped. That means you didn't trap the error and provide information. Fix your broken code.

  2. Broker's use a variety of naming patterns: EURUSD, EURUSDb, EURUSDc, EURUSDcheck, EURUSDct, EURUSDecn, EURUSDf, EURUSDh, EURUSDi, EURUSDm, EURUSDme, EURUSDmicro, EURUSDpro, EURUSDt, EURUSDx. “EUR.USD”, “EUR/USD”, “EUR/USD_ecn”, “EURUSD!”, “EURUSD#”, “EURUSD£”, “EURUSD..”, “EURUSD.”, “EURUSD.a”, “EURUSD.ar”, “EURUSD.ax/a>”, “EURUSD.c”, “EURUSD.cfx”, “BRENT.cmd”, “EURUSD.ecn” and “EURUSD.ECN”, “EURUSD.G”, “EURUSD.i”, “BTCUSD.lts”, “EURUSD.m”, “EURUSD.p”, “EURUSD.pro”, “EURUSD.r”, “EURUSD.t/a>”, “EURUSD.SBe”, “EURUSD.stp”, “EURUSD.s”, “EURUSD.z”, “EURUSD'”, “EURUSD@”, “EURUSD_i”, “EURGBP_0s”, “GBPUSD_SB”, “EURUSD-5”, “EURUSD-e/”, “EURUSD-g”, “EURUSD-m”, “EURUSD-sb”, “#XAUUSD”, “#FB”, “$WDAY”, and Financial symbols with “-”, “=”, “_”, and “+”

    If the pattern your broker uses doesn't match the pattern of your signal provider's broker, you can't copy the signal/open a trade. Switch brokers to one that has that adornment.

    If the naming pattern of your charts isn't exactly “BasQuo” then hard coded symbols fails. Don't hard code things; just use the predefined _Symbol, or add/remove the adornments during processing.