Advertisement IC Markets

Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Optimize MetaTrader 4, MetaTrader 5, cTrader, and TradingView for speed. Discuss Level II Market Depth (DOM), custom hotkeys, and volume indicators.
FXS Prop Desk
Posts: 415
Joined: Wed Oct 07, 2026 9:52 am

Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by FXS Prop Desk »

MT5 allows custom symbols built from your own data. That makes it possible to chart things the broker does not offer directly.

Examples:
  • A yield spread chart, imported from external data.
  • A synthetic currency index, such as a custom basket of USD pairs.
  • A ratio chart, e.g. gold divided by silver.
  • Imported tick data from another source for backtesting.
How it works:
  • Create the symbol in the Symbols window (Custom section).
  • Import bars or ticks from a CSV file, or update them with an MQL5 script.
  • Use the symbol on charts and in the Strategy Tester like any other.
Limitations: custom symbols cannot be traded directly, and data must be kept up to date by your own script.

Have you created custom symbols in MT5, and what did you use them for?
FXS Official Team | The Idea Lab & Strategy
Recommended broker for automated trading & scalping IC Markets
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

FXS Prop Desk wrote: Wed Oct 07, 2026 3:58 pm MT5 allows custom symbols built from your own data. That makes it possible to chart things the broker does not offer directly.

Examples:
  • A yield spread chart, imported from external data.
  • A synthetic currency index, such as a custom basket of USD pairs.
  • A ratio chart, e.g. gold divided by silver.
  • Imported tick data from another source for backtesting.
How it works:
  • Create the symbol in the Symbols window (Custom section).
  • Import bars or ticks from a CSV file, or update them with an MQL5 script.
  • Use the symbol on charts and in the Strategy Tester like any other.
Limitations: custom symbols cannot be traded directly, and data must be kept up to date by your own script.

Have you created custom symbols in MT5, and what did you use them for?
Hi Fairman,

how are you? Interesting topic.

MT5’s Custom Symbol architecture is arguably one of the most powerful—and often underutilized—features for institutional-style quantitative analysis. By breaking free from the broker's default feed, traders use custom symbols to transform abstract mathematical concepts into standard charts that indicators and Expert Advisors (EAs) can read natively.

Here is an extended look at how I help traders push MT5's Custom Symbols beyond the basics, how to overcome their limitations, and the advanced use cases they unlock.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

Advanced Use Cases for Custom Symbols

Beyond basic ratio charts or synthetic indices, quantitative traders utilize custom symbols for highly complex modeling:

Statistical Arbitrage (Pairs Trading) Spreads: Instead of calculating the spread between two correlated assets (like WTI and Brent, or AUDUSD and NZDUSD) inside an EA's logic, traders create a custom symbol that represents the raw spread (Asset A - Asset B). This allows them to apply standard MT5 indicators—like Bollinger Bands or RSI—directly to the spread chart to easily trigger mean-reversion EAs when the spread diverges.

True 99.9% Tick-Quality Backtesting: Broker data is notoriously gappy, which ruins scalping and high-frequency trading (HFT) backtests. Traders use custom symbols to import pristine, third-party tick data (e.g., from Dukascopy or Tickstory). By mapping this data to a custom symbol (e.g., EURUSD_Custom), they can run the MT5 Strategy Tester with absolute algorithmic precision, bypassing the broker's historical data limitations entirely.

Multi-Exchange Crypto Arbitrage: Traders can pipe real-time websocket data from external crypto exchanges (like Binance or Kraken) directly into an MT5 custom symbol. This allows them to chart "Binance BTC" against "Broker BTC" on the same MT5 terminal, running an EA that alerts them to latency arbitrage or price discrepancies.

Macro-Economic & Alternative Data Overlays: Because a custom symbol just requires a timestamp and a price, traders import time-series data for non-tradable metrics. This includes plotting the VIX, Treasury yields, or even custom order-book imbalance metrics on an MT5 chart to use as a master filter for their Forex EAs.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

Automating the "Limitation" (The MQL5 Data Feeder)

You correctly noted the primary limitation: custom symbols cannot be traded directly, and data must be kept up to date.

To solve the data update problem, manual CSV imports are usually abandoned in favor of an MQL5 Data Feeder EA. This is a lightweight script attached to a single background chart on a VPS that does the heavy lifting:

Creation: The script uses CustomSymbolCreate() to generate the symbol programmatically if it doesn't exist, mirroring the contract specifications (lot size, tick size, margin currency) of a real asset.

Calculation: It continuously monitors real-time market ticks via the OnTick() event. If building a synthetic EUR/GBP from EUR/USD and GBP/USD, it calculates the cross mathematically on every tick.

Injection: It uses CustomTicksAdd() or CustomRatesUpdate() to inject the newly calculated tick directly into the custom symbol's database in real time.

Because this feeder runs seamlessly in the background, the custom symbol behaves exactly like a live broker feed. You can open a chart, attach standard indicators, and watch the synthetic candles form in real time.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

The Execution Workaround

While you cannot send a OrderSend() command directly to a custom symbol, traders easily bypass this in their EA logic.

If an EA is running on the custom Yield_Spread chart and generates a "Buy" signal, the EA is simply programmed to route the actual execution to the underlying real assets (e.g., buying Asset A and selling Asset B simultaneously). The custom symbol acts purely as the analytical "brain" and charting interface, while the MQL5 code handles the real-world routing.

Are you looking to build a specific synthetic asset or import a particular dataset for backtesting? I can help you write the MQL5 script to automate the data injection.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

This is a complete MQL5 Expert Advisor (EA) designed to act as a Real-Time Data Feeder.

Instead of manually importing CSVs, this script runs in the background, continuously calculates the price spread between two assets (e.g., EURUSD - GBPUSD), creates the custom symbol if it doesn't exist, and injects the new synthetic ticks directly into MT5.

The MQL5 Spread Feeder Script

Code: Select all

//+------------------------------------------------------------------+
//|                                        SyntheticSpreadFeeder.mq5 |
//|                                      Quantitative Data Generator |
//+------------------------------------------------------------------+
#property copyright "Quantitative Developer"
#property link      ""
#property version   "1.00"
#property strict

//--- Input Parameters
input string InpSymbolA = "EURUSD";                  // Leg A (Base)
input string InpSymbolB = "GBPUSD";                  // Leg B (Subtract)
input string InpCustomSymbol = "EUR_GBP_SPREAD";     // Custom Symbol Name
input string InpCustomPath = "Custom\\Spreads\\EUR_GBP_SPREAD"; // Path in Market Watch

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   // 1. Ensure both data source symbols are available in Market Watch
   SymbolSelect(InpSymbolA, true);
   SymbolSelect(InpSymbolB, true);

   // 2. Check if the custom symbol exists; create it if it doesn't
   if(!SymbolInfoInteger(InpCustomSymbol, SYMBOL_CUSTOM))
     {
      // Create the symbol using Leg A as a baseline template
      // This automatically copies the tick size, digits, and margin requirements
      if(!CustomSymbolCreate(InpCustomSymbol, InpCustomPath, InpSymbolA))
        {
         Print("Critical Error: Could not create custom symbol. Code: ", GetLastError());
         return(INIT_FAILED);
        }
      Print("Successfully created custom symbol: ", InpCustomSymbol);
     }
   
   // 3. Enable the custom symbol in Market Watch so charts can open it
   SymbolSelect(InpCustomSymbol, true);

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert tick function (Executes every time Leg A changes price)   |
//+------------------------------------------------------------------+
void OnTick()
  {
   MqlTick tickA, tickB;
   
   // Fetch the absolute latest ticks for both legs
   if(SymbolInfoTick(InpSymbolA, tickA) && SymbolInfoTick(InpSymbolB, tickB))
     {
      MqlTick customTick[1]; // Array required by CustomTicksAdd
      
      // Calculate the synthetic spread with institutional pricing logic
      // To BUY the spread: Buy A (Ask) and Sell B (Bid)
      // To SELL the spread: Sell A (Bid) and Buy B (Ask)
      double syntheticAsk = tickA.ask - tickB.bid;
      double syntheticBid = tickA.bid - tickB.ask;
      
      // Synchronize the timestamp to the most recent tick of the two
      long latest_time_msc = MathMax(tickA.time_msc, tickB.time_msc);
      
      // Populate the custom tick structure
      customTick[0].time_msc = latest_time_msc; 
      customTick[0].time     = (datetime)(latest_time_msc / 1000);
      
      // Normalize to the digits of the custom symbol to prevent chart rendering errors
      int digits = (int)SymbolInfoInteger(InpCustomSymbol, SYMBOL_DIGITS);
      customTick[0].bid      = NormalizeDouble(syntheticBid, digits);
      customTick[0].ask      = NormalizeDouble(syntheticAsk, digits);
      
      customTick[0].last     = 0.0;
      customTick[0].volume   = 0;
      customTick[0].flags    = TICK_FLAG_BID | TICK_FLAG_ASK; // Flag that both updated
      
      // 4. Inject the calculated tick into the Custom Symbol's database
      int ticks_added = CustomTicksAdd(InpCustomSymbol, customTick);
      
      if(ticks_added < 1)
        {
         // Error 5304 is a common, harmless duplicate tick error. We only flag structural errors.
         if(GetLastError() != 5304) 
           Print("Warning: Failed to inject tick. Error: ", GetLastError());
        }
     }
  }
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

How to Install and Run It

Compile: Open MetaEditor (press F4 in MT5). Go to File > New > Expert Advisor (template). Name it SyntheticSpreadFeeder. Delete the default code, paste the code above, and click Compile.

Attach: Go back to your MT5 terminal. Open a standard chart for Leg A (e.g., EURUSD). Drag the SyntheticSpreadFeeder EA from your Navigator window onto this chart.

Verify: Check your Market Watch window. You will see EUR_GBP_SPREAD appear. Right-click it and select Chart Window.

Watch it build: As long as the EA is running on the original EURUSD chart, you will see 1-minute (and tick-level) candles actively forming on your new custom EUR_GBP_SPREAD chart in real-time.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

The Core Mechanisms Used

CustomSymbolCreate(): Uses an existing asset (InpSymbolA) as a template. This is a massive time-saver, as it automatically copies the required contract specifications (pip size, point value, swap rates) so your indicators math out correctly without you manually scripting 50 individual symbol properties.

MathMax(tickA.time_msc, tickB.time_msc): Standard MT5 charts track time down to the millisecond. By comparing the timestamps of Asset A and Asset B and choosing the highest one, we ensure our custom symbol's timeline is perfectly synchronized with live market data, preventing "future-tick" errors in the MT5 database.

CustomTicksAdd(): The engine of the script. MT5 automatically takes these raw injected ticks and builds the M1, M5, H1, and D1 OHLC (Open, High, Low, Close) candles for you instantly.

If you plan to backtest this, you will need to modify the script slightly to loop through historical data using CopyTicks() rather than OnTick(), so it can build a multi-year historical file for the Strategy Tester.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

To elevate this from a simple real-time script to a professional-grade institutional tool, we need to solve the biggest problem with custom symbols: historical data.
A pro script doesn't just start recording today; it instantly backfills weeks or months of historical data so you can apply indicators and run backtests the second you open the chart.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Custom Symbols in MT5: Building Synthetic Pairs and Spread Charts

Post by PTScalper »

Here is the upgraded "Pro" version. It includes:

Historical M1 Backfilling: Automatically downloads and synchronizes historical data for both legs, applies the correct spread mathematics, and builds the historical chart instantly.

Advanced Spread Mathematics: Correctly calculates OHLC (Open, High, Low, Close) extremes. (e.g., The High of a spread is not High A - High B; it is High A - Low B).

Terminal HUD (Heads Up Display): Projects a real-time data dashboard on the chart to monitor latency and tick flow.

CPU Optimization: Filters out duplicate ticks and validates data terminal synchronization before injecting.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Post Reply