Symbol name issue in EA

 

I developed an EA for EURUSD only and it is working exactly as expected on some brokers. but when i tried it on exness, it started generating errors because of EURUSDm there.

i do not want to use a user input field for currency pair selection. how can i resolve this issue?

 

CurrencyBase

Gets the name of symbol base currency

CurrencyProfit

Gets the profit currency name

Documentation on MQL5: Standard Library / Trade Classes / CSymbolInfo / CurrencyBase
Documentation on MQL5: Standard Library / Trade Classes / CSymbolInfo / CurrencyBase
  • www.mql5.com
CurrencyBase - CSymbolInfo - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Broker's use a variety of naming patterns: EURUSD, EURUSDc, EURUSDct, EURUSDecn, EURUSDi, EURUSDm, EURUSDme, EURUSDpro, EURUSDt, "EUR.USD", "EUR/USD", "EURUSD!", "EURUSD#", "EURUSD.", "EURUSD..", "EURUSD.c", "EURUSD.cfx", "EURUSD.G", "EURUSD.i", "EURUSD.r", "EURUSD.SBe", "EURUSD.stp", "EURUSD+", "EURUSD-5", "EURUSD-g", "EURUSD-m", "EURUSD-sb", etc., 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.
          I need to know how to fill an enum or get a drop down list, with a string array :)) - MQL4 programming forum #10 2020.06.12

 
William Roeder:

Don't hard code things;

No i do not want to hard code anything in my EA, if a solution exists in lib.

William Roeder:

just use the predefined _Symbol,

Will this work for trading only in EURUSD even if EA is attached to any other chart e.g. GBPUSD? I studied it but did not find a solution.

William Roeder:

or add/remove the adornments during processing.
          I need to know how to fill an enum or get a drop down list, with a string array :)) - MQL4 programming forum #10 2020.06.12

This helped. Thank you BOSS :)

 
Qæs: Will this work for trading only in EURUSD even if EA is attached to any other chart e.g. GBPUSD?

Of course not. Put it on the chart you want to trade.