Loading…

Auto Learning Symbol Mapper

Every broker names the same instrument differently - "EURUSD" on one server, "EURUSDm" or "EURUSD.a" or "EURUSDpro" on another - and a copy chain that assumes the master's raw symbol name exists verbatim on the slave breaks the moment it doesn't. Hand-maintaining a suffix mapping per broker is exactly the kind of bookkeeping that goes stale the first time a broker changes its naming. This EA reads a shared file of raw symbol names (written by a master or bridge process, one line per symbol with that symbol's own contract size), and for each one tries, in order: the exact name unmodified; the suffix this run has already learned from a previous symbol; and only if neither works, a full scan of every symbol on the connected server (SymbolsTotal(true)) looking for the shortest-suffix match on that raw name's core. The first successful full-scan match teaches the suffix for the rest of the run - a broker that uses one consistent suffix across its whole symbol list only ever pays the expensive full scan once. Alongside the mapped symbol name it also computes a lot-scale ratio from the master's stated contract size divided by this broker's own live contract size for that symbol, since gold, indices and some CFDs use different contract sizes across brokers even when the pip value looks similar - a ratio a downstream copier can multiply its own lot size by to compensate. The learned mapping table is republished to a shared file every poll for other EAs in a copy chain to read - this project does not itself place any trade or open any position, on either platform. Notes and limitations - Tracks at most 100 distinct raw symbols in one run (a documented fixed-array cap, MAX_MAPPINGS in the source); a raw symbol beyond that logs a warning and is skipped. - The suffix-matching heuristic is "shortest remainder that starts with the raw name" - on a broker whose symbol list happens to contain several plausible near-matches for a short raw name, the wrong one could in principle be picked. Always check the Experts log's "learned" lines against the intended list once after first setup. - Once a raw symbol resolves successfully it is never re-scanned, even if that broker symbol later becomes unavailable - restart the EA to force a fresh resolution pass. - Does not itself validate that the mapped symbol is actually tradable (market hours, broker restrictions); it only confirms the name exists on the server's symbol list. - Publishes a lot-scale ratio derived from each side's own live contract size (never hardcoded) - a downstream copier is still responsible for applying its own lot-step/min-lot/max-lot normalisation after multiplying by this ratio. - Places no trade and opens no position on either platform, so it does not interact with netting or hedging in any way; it is safe to run alongside any account type.

Expert advisor · MT5 · v1.0 · Free

About Auto Learning Symbol Mapper

Auto Learning Symbol Mapper is a script for MetaTrader 5. It has 4 settings, such as Raw symbol file, Mapped symbol file and Poll interval sec. MQL source code included.

Files in the download: AutoLearningSymbolMapper.ex5, AutoLearningSymbolMapper.mq5, AutoLearningSymbolMapper.txt.

Settings

SettingDefaultWhat it does
Raw symbol fileSymbolMap_Raw.csvShared (FILE_COMMON) input: one line per raw symbol, "RawSymbol,MasterContractSize"
Mapped symbol fileSymbolMap_Learned.csvShared (FILE_COMMON) output for the rest of the copy chain to read
Poll interval sec10Seconds between rescans of the raw symbol file
Max suffix len8A broker symbol's remainder after the raw name's core must be no longer than this to count as a suff

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: EURUSD · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria